/**
 * AllEscape Puzzle Widget - Styles
 * نسخه: 1.0.3
 * سبک: Dark Mode با رنگ برند نارنجی نئون
 */

/* ==================== VARIABLES ==================== */
:root {
    --allescape-dark-bg: #121212;
    --allescape-dark-secondary: #1a1a1a;
    --allescape-brand-orange: #ff5a00;
    --allescape-text-light: #e0e0e0;
    --allescape-overlay: rgba(0, 0, 0, 0.7);
    --allescape-glow: 0 0 20px rgba(255, 90, 0, 0.6);
    --allescape-transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== RESET & BASE ==================== */
.allescape-widget-container *,
.allescape-bottom-sheet * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==================== DESKTOP WIDGET ==================== */
/* [اصلاح شده]: تغییر margin از 40px به 0 برای حذف فاصله اضافی بالا و پایین شرت‌کد */
.allescape-widget-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto; 
    border-radius: 16px;
    overflow: hidden;
    background: var(--allescape-dark-bg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    aspect-ratio: 1 / 1;
}

/* Video Background */
.allescape-video-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.allescape-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.allescape-video-overlay {
    /* [جراحی شده]: تنظیم روکش به صورت نامرئی در حالت پیش‌فرض با افکت نرم */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: var(--allescape-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* [اضافه شده]: کلاسی که پس از اتمام ویدیو، روکش تیره را نمایان می‌کند */
.allescape-widget-container.video-ended .allescape-video-overlay {
    opacity: 1;
    pointer-events: auto;
}

/* Content Layer */
.allescape-content {
    position: relative;
    z-index: 3;
    padding: 20px;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ==================== PUZZLE STATE ==================== */
.allescape-puzzle-state {
    animation: fadeInUp 0.8s ease-out;
}

.allescape-mystery-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--allescape-text-light);
    line-height: 1.5;
    margin-bottom: 8px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
}

/* Locks Container */
.allescape-locks-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 8px 0;
}

/* نمایش عمودی آیکون و حرف زیر آن */
.allescape-lock {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 28px;
    color: #555;
    cursor: pointer;
    transition: var(--allescape-transition);
    user-select: none;
}

/* استایل حروف زیر قفل */
.allescape-lock-label {
    font-size: 15px;
    font-family: monospace;
    font-weight: 900;
    color: #555;
    transition: var(--allescape-transition);
}

.allescape-lock:hover {
    transform: scale(1.1);
}

.allescape-lock.unlocked i,
.allescape-lock.unlocked .allescape-lock-label {
    color: var(--allescape-brand-orange);
    filter: drop-shadow(var(--allescape-glow));
}
.allescape-lock.unlocked i {
    animation: unlockShake 0.5s ease-in-out;
}

.allescape-lock.error i,
.allescape-lock.error .allescape-lock-label {
    color: #808080 !important;
    filter: none;
}
.allescape-lock.error {
    animation: errorShake 0.4s ease-in-out;
}

/* [اصلاح شده - جراحی‌شده]: استایل دکمه بازبینی سرنخ و جلوگیری از ارث‌بری قالب */
.allescape-replay-btn {
    background: transparent !important;
    border: 1px solid rgba(255, 90, 0, 0.5) !important;
    color: var(--allescape-brand-orange) !important;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 10px;
    font-family: inherit;
    font-size: 14px;
    transition: var(--allescape-transition);
}
.allescape-replay-btn:hover,
.allescape-replay-btn:focus,
.allescape-replay-btn:active {
    background: rgba(255, 90, 0, 0.1) !important;
    border-color: var(--allescape-brand-orange) !important;
    color: var(--allescape-brand-orange) !important;
    box-shadow: var(--allescape-glow) !important;
    outline: none !important;
}

/* حالت پیش‌فرض: مخفی برای انیمیشن اسکرول */
.allescape-animate-text,
.allescape-animate-locks {
    opacity: 0;
    transform: translateY(30px);
}

/* حالت visible بعد از اسکرول/ویدیو */
.allescape-animate-text.visible {
    animation: fadeInUp 0.8s ease-out forwards;
}

.allescape-animate-locks.visible {
    animation: fadeInUp 0.8s ease-out 0.3s forwards;
}

/* ==================== SUCCESS STATE ==================== */
.allescape-success-state {
    opacity: 0;
    transform: scale(0.8);
}

.allescape-success-state.active {
    animation: scaleIn 0.6s ease-out forwards;
}

.allescape-success-icon {
    font-size: 40px;
    color: var(--allescape-brand-orange);
    margin-bottom: 8px;
    filter: drop-shadow(var(--allescape-glow));
    animation: bounceIn 1s ease-out;
}

.allescape-success-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--allescape-brand-orange);
    margin-bottom: 6px;
    text-shadow: var(--allescape-glow);
}

.allescape-success-subtitle {
    font-size: 12px;
    color: var(--allescape-text-light);
    margin-bottom: 12px;
    line-height: 1.6;
}

/* CTA Button */
.allescape-cta-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 14px;
    font-size: 12px;
    white-space: nowrap; 
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--allescape-brand-orange), #ff7a33);
    border: none;
    border-radius: 50px;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 90, 0, 0.4);
    transition: var(--allescape-transition);
    position: relative;
    overflow: hidden;
}

.allescape-cta-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 32px rgba(255, 90, 0, 0.6);
}

/* ==================== MOBILE FAB ==================== */
.allescape-mobile-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: var(--allescape-brand-orange);
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(255, 90, 0, 0.5);
    z-index: 9998;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    animation: fabPulse 2s infinite;
    transition: var(--allescape-transition);
}

.allescape-mobile-fab:hover {
    transform: scale(1.1);
}

/* ==================== BOTTOM SHEET ==================== */
.allescape-bottom-sheet {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
}

.allescape-bottom-sheet.active {
    display: block;
}

.allescape-bottom-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1;
}

.allescape-bottom-sheet-content {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 90vh;
    background: var(--allescape-dark-bg);
    border-radius: 24px 24px 0 0;
    z-index: 2;
    overflow-y: auto;
    animation: slideUp 0.4s ease-out;
    padding-bottom: 20px;
}

.allescape-close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    transition: var(--allescape-transition);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bounceIn {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-10px); }
}

@keyframes unlockShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px) rotate(-5deg); }
    75% { transform: translateX(8px) rotate(5deg); }
}

/* انیمیشن لرزش خطا */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px) rotate(-5deg); }
    75% { transform: translateX(6px) rotate(5deg); }
}

@keyframes fabPulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(255, 90, 0, 0.5); }
    50% { box-shadow: 0 4px 24px rgba(255, 90, 0, 0.8); }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .allescape-widget-container { display: none; }
    .allescape-mobile-fab { display: flex; }
    .allescape-bottom-sheet-content .allescape-content {
        padding: 60px 20px 30px;
        min-height: auto;
    }
    .allescape-mystery-text { font-size: 18px; }
    .allescape-locks-container { gap: 16px; }
    .allescape-lock { font-size: 30px; }
    .allescape-lock-label { font-size: 18px; }
    .allescape-success-icon { font-size: 60px; }
    .allescape-success-title { font-size: 26px; }
    .allescape-success-subtitle { font-size: 14px; }
    .allescape-cta-button { font-size: 13px; padding: 8px 16px; }
}

@media (max-width: 480px) {
    .allescape-mystery-text { font-size: 16px; }
    .allescape-locks-container { gap: 12px; }
    .allescape-lock { font-size: 26px; }
    .allescape-lock-label { font-size: 16px; }
    .allescape-cta-button { font-size: 12px; padding: 6px 14px; }
}

[dir="rtl"] .allescape-mobile-fab { right: auto; left: 24px; }
[dir="rtl"] .allescape-close-button { right: auto; left: 16px; }
