/* ============================================================
   MOBILE FIXES & UX ENHANCEMENTS
   Подключается после style.css, не ломает десктоп
   ============================================================ */

/* Footer nav links — защита от Mango (не используем класс accent) */
.footer-link {
    color: var(--accent, #4ade80);
    text-decoration: none;
    transition: color .2s ease;
}
.footer-link:hover {
    color: #86efac;
}

/* A11y — скрыть визуально, но оставить для скрин-ридеров */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ----------------------------------------------------------
   1. Статичный текст hero — убираем мигающий курсор
   ---------------------------------------------------------- */
.hero-tagline-anim {
    border-right: none !important;
    animation: none !important;
    padding-right: 0 !important;
}

/* ----------------------------------------------------------
   2. STATS — 2×2 grid на мобиле
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    .stats-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: stretch;
        border-radius: 16px;
        overflow: hidden;
    }
    .stat-div {
        display: none !important;
    }
    .stat-item {
        flex: 0 0 50%;
        width: 50%;
        padding: 1rem .5rem;
        border-right: 1px solid rgba(255,255,255,.08);
        border-bottom: 1px solid rgba(255,255,255,.08);
        box-sizing: border-box;
    }
    /* правая колонка — без правого бордера */
    .stat-item:nth-of-type(even) {
        border-right: none;
    }
    /* нижняя строка — без нижнего бордера */
    .stat-item:nth-of-type(3),
    .stat-item:nth-of-type(4) {
        border-bottom: none;
    }
    .stat-num {
        font-size: 1.3rem !important;
    }
    .stat-label {
        font-size: .6rem !important;
        white-space: normal;
    }
}

/* ----------------------------------------------------------
   3. STICKY STACK — полностью отключаем, единый фон
   ---------------------------------------------------------- */
.stack-card {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border-top: none !important;
    /* Единый неделимый фон — перекрывает инлайн background:#xxx */
    background: transparent !important;
}
.stack-card + .stack-card {
    border-top: none !important;
}
/* Убираем градиентные переходы между секциями */
.section-bg::before,
.section-bg::after {
    display: none !important;
}
.section-bg {
    background: transparent !important;
}
.section {
    background: transparent !important;
}

/* ----------------------------------------------------------
   3b. ЕДИНЫЙ ФОН СТРАНИЦЫ — плавный градиент сверху вниз
   ---------------------------------------------------------- */
body {
    background:
        radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34, 197, 94, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 100% 40%, rgba(74, 222, 128, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse 70% 50% at 0% 70%, rgba(96, 165, 250, 0.04) 0%, transparent 50%),
        linear-gradient(180deg, #12141c 0%, #0f1118 100%) !important;
    background-attachment: fixed !important;
}

/* Декоративные плавающие круги (органичность) */
body::before {
    content: '';
    position: fixed;
    top: 10%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(74, 222, 128, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: orbFloat 20s ease-in-out infinite;
}
body::after {
    content: '';
    position: fixed;
    bottom: 5%;
    left: -15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    animation: orbFloat 25s ease-in-out infinite reverse;
}
@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
}

/* Контент поверх декора */
main, header, footer, .mob-bar, #chatWidget {
    position: relative;
    z-index: 1;
}

/* ----------------------------------------------------------
   3c. АНИМАЦИЯ ПОЯВЛЕНИЯ/ИСЧЕЗАНИЯ СЕКЦИЙ
   Используем только opacity — transform на stack-card ломает
   position:fixed (chat, mob-bar) создавая новый stacking context
   ---------------------------------------------------------- */
.stack-card {
    opacity: 0;
    transition: opacity 1s ease;
}
.stack-card.in-view {
    opacity: 1;
}
/* Первая секция (hero) — всегда видна */
.stack-card[style*="--i:0"] {
    opacity: 1;
}

/* Плавные границы внутри секций — легкое свечение по верху */
.stack-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(74, 222, 128, 0.15), transparent);
    pointer-events: none;
}
.stack-card:first-child::before {
    display: none;
}

/* ----------------------------------------------------------
   4. STICKY FOOTER PADDING — контент не перекрывается mob-bar
   ---------------------------------------------------------- */
@media (max-width: 767px) {
    body {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Единый padding секций */
    .section,
    .stack-card > section.section,
    .stack-card > section {
        padding: 2rem 1rem !important;
        margin: 0 !important;
    }

    /* Hero — компактнее */
    .hero {
        padding: 1.5rem 1rem 2.5rem !important;
    }
    .hero h1 {
        font-size: clamp(2.25rem, 11vw, 3.25rem) !important;
        line-height: 1 !important;
        margin: .75rem 0 .5rem !important;
    }
    .hero-city {
        font-size: 1rem !important;
        margin-bottom: 1rem !important;
    }

    /* Section-title — крупнее подписей */
    .section-title {
        font-size: 1.625rem !important;
        line-height: 1.15 !important;
        margin-bottom: 1.25rem !important;
    }

    /* Единый container */
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        max-width: 100% !important;
    }

    /* Trust-row — не переносить, сжать */
    .hero-trust-row {
        gap: .5rem !important;
        font-size: .75rem !important;
    }
    .hero-trust-sep {
        display: none !important;
    }
}

/* ----------------------------------------------------------
   5. PULSE — зелёная точка "Онлайн сейчас" (усиленная)
   ---------------------------------------------------------- */
@keyframes livePulse {
    0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.7); }
    60%  { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
    100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
.realtime-dot {
    animation: realtimePulse 1.8s ease-in-out infinite,
               livePulse 1.8s ease-in-out infinite !important;
}

/* ----------------------------------------------------------
   7. SCROLL PROGRESS BAR
   ---------------------------------------------------------- */
#readProgress {
    position: fixed;
    top: 52px; /* под хедером */
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #22c55e, #4ade80);
    z-index: 150;
    transition: width .1s linear;
    pointer-events: none;
    border-radius: 0 2px 2px 0;
}


/* ----------------------------------------------------------
   8. TIMELINE STEP HIGHLIGHT
   ---------------------------------------------------------- */
.step-circle {
    transition: background .4s ease, color .4s ease, box-shadow .4s ease;
}
.step-row.active .step-circle {
    background: linear-gradient(135deg, #16a34a, #22c55e) !important;
    color: #fff !important;
    box-shadow: 0 0 0 4px rgba(34,197,94,.25);
}
.step-row.active .step-content h3 {
    color: #4ade80;
    transition: color .4s ease;
}

/* ----------------------------------------------------------
   10. LIGHTBOX
   ---------------------------------------------------------- */
#lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.9);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .3s ease;
    cursor: zoom-out;
}
#lightbox-overlay.visible {
    opacity: 1;
}
#lightbox-overlay img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: 0 8px 60px rgba(0,0,0,.6);
    transform: scale(.9);
    transition: transform .3s ease;
    pointer-events: none;
}
#lightbox-overlay.visible img {
    transform: scale(1);
}

/* ----------------------------------------------------------
   11. QUIZ MODAL
   ---------------------------------------------------------- */
#quiz-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}
#quiz-modal.open {
    opacity: 1;
    pointer-events: auto;
}
.quiz-sheet {
    background: #1e2130;
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 560px;
    padding: 1.5rem 1.5rem 2rem;
    transform: translateY(100%);
    transition: transform .35s cubic-bezier(.22,1,.36,1);
    max-height: 90vh;
    overflow-y: auto;
}
#quiz-modal.open .quiz-sheet {
    transform: translateY(0) !important;
}
/* Принудительно показываем активный шаг — только в #quiz-modal */
#quiz-modal .quiz-step { display: none !important; }
#quiz-modal .quiz-step.active { display: block !important; }

/* callModal — шаги квиза */
#callModal .quiz-step { display: block; }
#callModal .quiz-step.hidden { display: none !important; }
.quiz-handle {
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,.15);
    border-radius: 2px;
    margin: 0 auto 1.5rem;
}
.quiz-step {
    display: none;
}
.quiz-step.active {
    display: block;
}
.quiz-step-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: .5rem;
}
.quiz-step-sub {
    font-size: .8125rem;
    color: rgba(255,255,255,.5);
    margin-bottom: 1.25rem;
}
.quiz-progress {
    display: flex;
    gap: .375rem;
    margin-bottom: 1.5rem;
}
.quiz-progress-dot {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,.12);
    transition: background .3s ease;
}
.quiz-progress-dot.done {
    background: #22c55e;
}
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: .625rem;
    margin-bottom: 1.5rem;
}
.quiz-option {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    padding: .875rem 1rem;
    color: #e8eaf0;
    font-size: .875rem;
    cursor: pointer;
    text-align: left;
    transition: background .2s, border-color .2s;
}
.quiz-option:hover,
.quiz-option.selected {
    background: rgba(34,197,94,.1);
    border-color: #22c55e;
    color: #fff;
}
.quiz-nav {
    display: flex;
    gap: .75rem;
}
.quiz-btn-next {
    flex: 1;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: .875rem;
    font-size: .9375rem;
    font-weight: 700;
    cursor: pointer;
}
.quiz-btn-back {
    background: rgba(255,255,255,.07);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: .875rem 1.25rem;
    font-size: .9375rem;
    cursor: pointer;
}

/* ----------------------------------------------------------
   12. FORM — privacy checkbox
   ---------------------------------------------------------- */
.form-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .875rem;
    cursor: pointer;
    color: rgba(255,255,255,.65);
    font-size: .8125rem;
    line-height: 1.4;
}
.form-checkbox-label a {
    color: #4ade80;
    text-decoration: underline;
}
.form-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    accent-color: #22c55e;
    cursor: pointer;
}
.btn-accent:disabled,
.btn-accent[disabled] {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ----------------------------------------------------------
   13. COOKIE CONSENT BANNER
   ---------------------------------------------------------- */
#cookieBanner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 8000;
    background: rgba(18,22,36,.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    transform: translateY(0);
    transition: transform .35s ease;
}
#cookieBanner.hidden {
    transform: translateY(110%);
}
.cookie-text {
    color: rgba(255,255,255,.75);
    font-size: .8125rem;
    line-height: 1.5;
    flex: 1;
    min-width: 200px;
}
.cookie-text a {
    color: #4ade80;
    text-decoration: underline;
}
.cookie-actions {
    display: flex;
    gap: .625rem;
    flex-shrink: 0;
}
.cookie-btn-accept {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: .5rem 1.125rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
}
.cookie-btn-decline {
    background: rgba(255,255,255,.07);
    color: rgba(255,255,255,.65);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    padding: .5rem 1rem;
    font-size: .875rem;
    cursor: pointer;
}
@media (max-width: 767px) {
    #cookieBanner {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
}

/* ----------------------------------------------------------
   14. HERO — Yandex rating widget
   ---------------------------------------------------------- */
.hero-ya-rating {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: block;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,.45);
    border: 1px solid rgba(255,255,255,.08);
    transition: transform .25s ease, box-shadow .25s ease;
    text-decoration: none;
    background: rgba(20,24,36,.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10;
}
.hero-ya-rating:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,.55);
}
.hero-ya-rating iframe {
    display: block;
    pointer-events: none;
}
/* --- Мобайл: виджет под поиском, компактный --- */
@media (max-width: 768px) {
    .hero-ya-rating {
        position: static !important;
        display: inline-block !important;
        width: auto !important;
        max-width: 220px;
        margin: 1rem 0 0 0 !important;
        right: auto !important;
        bottom: auto !important;
        transform: none !important;
        border-radius: 10px;
    }
    .hero-ya-rating iframe {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ----------------------------------------------------------
   15. МОБАЙЛ: номер телефона — не переносить
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    .hero-phone-num {
        white-space: nowrap;
        font-size: clamp(.9rem, 4vw, 1.15rem) !important;
        letter-spacing: -.01em;
    }
    .mob-bar-call-num {
        white-space: nowrap;
        font-size: clamp(.75rem, 3.5vw, .9rem) !important;
    }
}

/* ----------------------------------------------------------
   16b. CHAT-WIDGET и MSG-WIDGET — принудительно справа
   ---------------------------------------------------------- */
#chatWidget,
.chat-widget {
    position: fixed !important;
    right: 1rem !important;
    left: auto !important;
    bottom: 1rem !important;
    z-index: 90 !important;
}
@media (max-width: 768px) {
    #chatWidget,
    .chat-widget {
        bottom: calc(58px + env(safe-area-inset-bottom) + .75rem) !important;
        right: .75rem !important;
    }
}
.msg-widget {
    left: auto !important;
    right: .75rem !important;
    align-items: flex-end !important;
}
.msg-buttons {
    align-items: flex-end !important;
}

/* ----------------------------------------------------------
   16a. Окно чата — всегда position:fixed снизу справа
   (chat-window вынесен из chat-widget в DOM → нет проблем с stacking context)
   ---------------------------------------------------------- */
.chat-window {
    position: fixed !important;
    bottom: 90px !important;
    right: 1rem !important;
    top: auto !important;
    left: auto !important;
    width: 340px !important;
    max-height: calc(100vh - 120px) !important;
    border-radius: 1.125rem !important;
    z-index: 9000 !important;
}

/* ----------------------------------------------------------
   16. МОБАЙЛ: чат — полноэкранный
   ---------------------------------------------------------- */
@media (max-width: 768px) {
    .chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 9999 !important;
    }
    .chat-window.hidden {
        display: none !important;
    }
    .chat-messages {
        flex: 1 1 auto !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        min-height: 0 !important;
    }
    .chat-quick-btns {
        flex-shrink: 0;
        overflow-x: auto;
        padding: .5rem .75rem;
    }
    .chat-input-row {
        flex-shrink: 0;
        padding-bottom: env(safe-area-inset-bottom, 12px) !important;
    }
}
