/* ============================================================
   IESA Interactive Tour — onboarding tooltips with spotlight
   Created: 2026-05-27. Dark theme only (default for all users).
   ============================================================ */

/* Overlay covers the whole page */
.iesa-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(0, 0, 0, 0.78);
    pointer-events: auto;
    opacity: 0;
    transition: opacity .25s ease;
    /* НЕ используем backdrop-filter — конфликтует с другими модалками
       которые тоже blur'ят страницу (welcome-modal раньше). С двойным
       blur весь UI становится нечитабельным. */
}
.iesa-tour-overlay.visible { opacity: 1; }

/* Spotlight = cut-out around the highlighted element.
   Implemented via box-shadow inset trick on a positioned element. */
.iesa-tour-spotlight {
    position: fixed;
    z-index: 9999;
    border-radius: 12px;
    box-shadow:
        0 0 0 4px rgba(220, 38, 38, 0.55),
        0 0 0 9999px rgba(0, 0, 0, 0.72),
        0 0 40px rgba(220, 38, 38, 0.35);
    transition: top .35s cubic-bezier(.22, 1, .36, 1),
                left .35s cubic-bezier(.22, 1, .36, 1),
                width .35s cubic-bezier(.22, 1, .36, 1),
                height .35s cubic-bezier(.22, 1, .36, 1);
    pointer-events: none;
    opacity: 0;
}
.iesa-tour-spotlight.visible { opacity: 1; }

/* Pulsing ring animation */
.iesa-tour-spotlight::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 16px;
    border: 2px solid rgba(220, 38, 38, 0.7);
    animation: iesa-tour-pulse 1.8s ease-in-out infinite;
    pointer-events: none;
}
@keyframes iesa-tour-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50%      { opacity: 0; transform: scale(1.08); }
}

/* Tooltip card */
.iesa-tour-tip {
    position: fixed;
    z-index: 10000;
    width: min(380px, calc(100vw - 32px));
    background: linear-gradient(145deg, #1a1a26, #12121c);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 16px;
    padding: 1.5rem 1.5rem 1.2rem;
    color: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7),
                0 0 0 1px rgba(220, 38, 38, 0.12);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s ease, transform .25s ease,
                top .35s cubic-bezier(.22, 1, .36, 1),
                left .35s cubic-bezier(.22, 1, .36, 1);
}
.iesa-tour-tip.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Arrow — НЕ показывается для центрированного варианта */
.iesa-tour-tip::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    background: #1a1a26;
    border-left: 1px solid rgba(220, 38, 38, 0.35);
    border-top: 1px solid rgba(220, 38, 38, 0.35);
    transform: rotate(45deg);
}
.iesa-tour-tip[data-pos="bottom"]::before { top: -8px; left: 28px; }
.iesa-tour-tip[data-pos="top"]::before {
    bottom: -8px; left: 28px;
    transform: rotate(-135deg);
}
.iesa-tour-tip[data-pos="right"]::before {
    left: -8px; top: 28px;
    transform: rotate(-45deg);
}
.iesa-tour-tip[data-pos="left"]::before {
    right: -8px; top: 28px;
    transform: rotate(135deg);
}
/* Centered welcome/finish — без стрелки, увеличенный размер */
.iesa-tour-tip[data-pos="center"]::before { display: none; }
.iesa-tour-tip[data-pos="center"] {
    width: min(420px, calc(100vw - 32px));
    padding: 1.75rem 1.75rem 1.4rem;
    text-align: center;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.75),
                0 0 0 1px rgba(220, 38, 38, 0.18),
                0 0 60px rgba(220, 38, 38, 0.15);
}
.iesa-tour-tip[data-pos="center"] .iesa-tour-title {
    font-size: 1.25rem;
}
.iesa-tour-tip[data-pos="center"] .iesa-tour-foot {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}
.iesa-tour-tip[data-pos="center"] .iesa-tour-actions {
    width: 100%;
}
.iesa-tour-tip[data-pos="center"] .iesa-tour-actions .iesa-tour-btn {
    width: 100%;
    padding: .75rem;
    font-size: .9rem;
}

/* Header row: step counter + close */
.iesa-tour-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .6rem;
}
.iesa-tour-counter {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #ef4444;
    font-family: 'Courier New', monospace;
}
.iesa-tour-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.55);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    padding: 0;
    font-size: .9rem;
    line-height: 1;
}
.iesa-tour-close:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #f87171;
    border-color: rgba(220, 38, 38, 0.3);
}

/* Body */
.iesa-tour-title {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0 0 .45rem;
    color: #fff;
    line-height: 1.3;
}
.iesa-tour-text {
    font-size: .88rem;
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.5;
    margin: 0 0 1rem;
}

/* Footer row: progress + actions */
.iesa-tour-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
}
.iesa-tour-progress {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}
.iesa-tour-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: background .2s, transform .2s;
}
.iesa-tour-dot.active {
    background: #ef4444;
    transform: scale(1.4);
}
.iesa-tour-dot.done { background: rgba(220, 38, 38, 0.45); }

.iesa-tour-actions {
    display: flex;
    gap: .5rem;
}
.iesa-tour-btn {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    border: none;
    color: #fff;
    font-size: .82rem;
    font-weight: 700;
    border-radius: 9px;
    padding: .5rem 1.1rem;
    cursor: pointer;
    transition: filter .15s, transform .15s;
    letter-spacing: .02em;
    font-family: inherit;
}
.iesa-tour-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.iesa-tour-btn:active { transform: translateY(0); }
.iesa-tour-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.55);
}
.iesa-tour-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* ── MOBILE — фиксим положение tooltip + размер spotlight ──────────── */
@media (max-width: 640px) {
    /* На узких экранах tooltip ВСЕГДА снизу экрана (sticky-bottom),
       занимает почти всю ширину. Это самое надёжное решение чтобы tooltip
       никогда не выезжал за край и не накрывал spotlight целиком. */
    .iesa-tour-tip {
        left: 12px !important;
        right: 12px !important;
        top: auto !important;
        bottom: 12px !important;
        width: auto !important;
        max-width: none !important;
        padding: 1rem 1.1rem .9rem;
        border-radius: 14px;
    }
    .iesa-tour-tip[data-pos="center"] {
        /* На mobile центрированный шаг тоже sticky-bottom для consistency */
        bottom: 12px !important;
        padding: 1.1rem 1.2rem 1rem;
        text-align: left;
    }
    .iesa-tour-tip[data-pos="center"] .iesa-tour-foot {
        flex-direction: row;
        gap: .75rem;
    }
    .iesa-tour-tip[data-pos="center"] .iesa-tour-actions .iesa-tour-btn {
        padding: .55rem 1.1rem;
        font-size: .85rem;
    }
    /* Стрелка не имеет смысла на mobile fixed-bottom — скрываем */
    .iesa-tour-tip::before { display: none; }

    .iesa-tour-title { font-size: 1rem; }
    .iesa-tour-text  { font-size: .82rem; line-height: 1.45; margin-bottom: .85rem; }

    /* На mobile spotlight чуть толще rim для читаемости */
    .iesa-tour-spotlight {
        box-shadow:
            0 0 0 3px rgba(220, 38, 38, 0.6),
            0 0 0 9999px rgba(0, 0, 0, 0.78),
            0 0 30px rgba(220, 38, 38, 0.4);
    }
}

/* iOS Safari: безопасные отступы под home-indicator */
@supports (padding: env(safe-area-inset-bottom)) {
    @media (max-width: 640px) {
        .iesa-tour-tip {
            bottom: calc(12px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* Element being highlighted — позиция z-index выше overlay чтобы был кликабельный
   (если нужно для интерактивных туров). По дефолту pointer-events: none на overlay. */
.iesa-tour-highlight {
    position: relative;
    z-index: 9999;
}
