/*
 * View Mode Control Styles
 * Создан: 2026-01-05
 * Цель: Скрытие блоков лендинга при активном режиме "Demo".
 */

/* 
 * Режим "Demo" (по умолчанию при заходе)
 * Скрываем все секции кроме Demo, Header и Footer.
 * Используем !important, чтобы перебить существующие стили без рефакторинга основного CSS.
 */
body.view-mode-demo #hero,
body.view-mode-demo #how,
body.view-mode-demo #features,
body.view-mode-demo #faq,
body.view-mode-demo #cta {
    display: none !important;
}

/* 
 * Убеждаемся, что Demo секция видна и имеет отступы.
 * В режиме Demo она становится основным контентом.
 */
body.view-mode-demo #demo {
    display: block !important;
    /* Уменьшен отступ сверху для сокращения пустого пространства (было 100px) */
    padding-top: 40px;
    /* Минимальная высота, чтобы футер не прилипал к верху на больших экранах */
    min-height: 60vh;
}

/* =========================================
   Mobile Header & Burger Menu (Task 2026-01-05)
   ========================================= */

/* Burger Button - Hidden by default */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 1001;
    /* Above mobile menu overlay */
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text, #0e1633);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Prevent scrolling when menu is open */
body.no-scroll {
    overflow: hidden;
}

@media (max-width: 900px) {
    .site-header {
        padding: 12px 20px;
        gap: 12px;
        flex-wrap: nowrap !important;
        /* Force single line */
        justify-content: flex-start;
        /* Control alignment locally */
    }

    /* 1. Simplify Title on Mobile */
    .site-header__brand {
        flex-shrink: 1;
        /* Allow brand to shrink */
        min-width: 0;
        /* Enable truncation for flex item */
        margin-right: auto;
        /* Push everything else to the right */
    }

    .site-header__title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
        /* Fallback */
        width: 100%;
        font-size: 0.95rem;
    }

    @media (max-width: 380px) {
        .site-header__title {
            display: none;
            /* Show icon only on very small screens if needed, or max-width small */
        }
    }

    /* 2. Show Burger Button */
    .mobile-menu-toggle {
        display: flex;
        flex-shrink: 0;
    }

    /* 3. Mobile Navigation Drawer (Enhanced) */
    .site-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(255, 255, 255, 0.95);
        /* Slightly more opaque */
        backdrop-filter: blur(16px);
        /* Heavy Blur */
        -webkit-backdrop-filter: blur(16px);
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 40px;
        z-index: 1000;

        /* Modern Slide/Fade transition */
        visibility: hidden;
        opacity: 0;
        transform: scale(0.95);
        transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);

        gap: 32px;
        font-size: 1.5rem;
        /* Bigger font */
        letter-spacing: -0.02em;
    }

    .site-nav a {
        font-weight: 700;
        color: var(--text);
        text-transform: capitalize;
        position: relative;
    }

    /* Interactive underline for menu items */
    .site-nav a::after {
        content: '';
        position: absolute;
        bottom: -4px;
        left: 0;
        width: 0;
        height: 2px;
        background: var(--primary);
        transition: width 0.3s ease;
    }

    .site-nav a:hover::after {
        width: 100%;
    }

    /* State: Menu Open */
    .site-header.is-menu-open .site-nav {
        visibility: visible;
        opacity: 1;
        transform: scale(1);
        pointer-events: auto;
    }

    /* Animate Burger Button to X */
    .site-header.is-menu-open .mobile-menu-toggle span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
        background-color: var(--primary);
    }

    .site-header.is-menu-open .mobile-menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    .site-header.is-menu-open .mobile-menu-toggle span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
        background-color: var(--primary);
    }

    /* 4. Actions: Hide Install, Position Language + Burger */
    .site-header__actions .btn[data-track="click_install_button"],
    .site-header__hint {
        display: none !important;
    }

    /* Actions container */
    .site-header__actions {
        flex-shrink: 0;
        margin-left: 0;
        /* Reset */
        margin-right: 16px;
        /* Gap between Lang and Burger */
        gap: 0;
    }

    /* Language Select enhancements for mobile */
    .site-header__language-select {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* 5. Mobile Demo Layout (Optimized for readability) */
    body.view-mode-demo #demo {
        display: flex !important;
        flex-direction: column;

        /* Отступ сверху для расстояния от хедера (было -32px) */
        padding-top: 24px !important;
        margin-top: 0 !important;

        padding-left: 12px;
        padding-right: 12px;
        gap: 0;
    }

    /* Override main padding when in demo mode for mobile */
    body.view-mode-demo main {
        padding-top: 12px !important;
    }

    /* Reorder Content: Interactive block first, Text second */
    #demo .section__heading {
        order: 2;
        /* Reduce gap */
        margin-top: 12px !important;
        margin-bottom: 24px !important;
        text-align: left;

        /* Optional: Visual shift up if still too low */
        transform: translateY(-10px);
    }

    #demo .demo__container {
        order: 1;
        width: 100%;
        max-width: 100%;
        /* Pull container up further to remove whitespace */
        margin-top: 0;
    }

    /* Typography fixes for Mobile */
    #demo h2 {
        font-size: 1.35rem !important;
        font-weight: 700;
        line-height: 1.25;
        margin-bottom: 8px;
    }

    #demo p {
        font-size: 0.9rem !important;
        line-height: 1.5;
        color: var(--muted);
    }

    /* Fix Privacy Note Layout on Mobile */
    .demo__note {
        display: flex !important;
        /* Force flex to control blocks */
        flex-direction: column !important;
        align-items: flex-start !important;
        font-size: 0.8rem;
        line-height: 1.4;
        margin-top: 12px;
        padding: 12px;
        width: 100%;
        box-sizing: border-box;
        gap: 16px !important;
        /* Large gap between blocks as requested */
    }

    /* Make each part a full block */
    .demo__note>span {
        display: block !important;
        width: 100%;
    }

    /* Security Line (Icon + Text) */
    .note__security {
        display: flex !important;
        align-items: center;
        gap: 8px;
    }

    .note__icon {
        margin: 0 !important;
        /* Reset margin since we use gap */
    }

    /* Dynamic rate limit text */
    #demo-rate-limit {
        font-weight: 600;
        /* Matches "3 requests remaining." style */
    }

    /* Desc text */
    .note__desc {
        color: #666;
    }

    /* Adjust buttons grid for very small screens */
    .system-buttons {
        gap: 6px;
    }

    .system-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}



/* Tablet Optimization (900px - 1200px) from previous task */
@media (min-width: 900px) and (max-width: 1200px) {
    .site-header {
        padding-left: 20px;
        padding-right: 20px;
        gap: 12px;
    }

    .site-nav {
        gap: 16px;
    }

    .site-nav a {
        font-size: 0.9rem;
    }
}

/* Prevent nav wrap globally */
.site-nav {
    flex-wrap: nowrap;
    white-space: nowrap;
}