/**
 * Squircle (corner-shape) — централизованно.
 * Вкл по умолчанию при поддержке браузером.
 * Выкл: KIT_SITE.ui.squircle = false → html.kit-squircle-off
 *   или setKitSquircle(false)
 *
 * Утилита: class="kit-squircle"
 *
 * НЕ трогаем:
 *  - pill (999px): кнопки, чипы
 *  - .header-mobile-container / .bottom-nav-container — свои капсулы + border
 *  - .gradient-border::before на кнопках/nav — mask-рамка ломается от corner-shape
 */

@supports (corner-shape: squircle) {
    html:not(.kit-squircle-off) {
        --kit-corner-shape: squircle;
        --kit-squircle-xl: 60px;
        --kit-squircle-lg: 40px;
        --kit-squircle-md: 28px;
        --kit-squircle-sm: 20px;
    }

    /* ─── Общие поверхности / карточки ─── */
    html:not(.kit-squircle-off) .kit-squircle,
    html:not(.kit-squircle-off) .kit-glass-card,
    html:not(.kit-squircle-off) .kit-glass-surface,
    html:not(.kit-squircle-off) .sandbox-feature-card,
    html:not(.kit-squircle-off) .integration-step-card,
    html:not(.kit-squircle-off) .bento-card,
    html:not(.kit-squircle-off) .faq-item,
    html:not(.kit-squircle-off) .pricing-card,
    html:not(.kit-squircle-off) .flow-card,
    html:not(.kit-squircle-off) .auth-card,
    html:not(.kit-squircle-off) .payment-return-card,
    html:not(.kit-squircle-off) .error-card,
    html:not(.kit-squircle-off) .flow-modal-card,
    html:not(.kit-squircle-off) .kit-visual,
    html:not(.kit-squircle-off) .kit-visual-bg,
    html:not(.kit-squircle-off) .kit-visual-shot,
    html:not(.kit-squircle-off) .hero-visual,
    html:not(.kit-squircle-off) .hero-visual-bg,
    html:not(.kit-squircle-off) .hero-screenshot,
    html:not(.kit-squircle-off) .hero-banner,
    html:not(.kit-squircle-off) .modules-visual,
    html:not(.kit-squircle-off) .projects-visual,
    html:not(.kit-squircle-off) .cta-visual,
    html:not(.kit-squircle-off) .download-hero-visual,
    html:not(.kit-squircle-off) .sandbox-feature-visual,
    html:not(.kit-squircle-off) .bento-card-visual,
    html:not(.kit-squircle-off) .integration-step-visual,
    html:not(.kit-squircle-off) .open-core-section.sandbox-section,
    html:not(.kit-squircle-off) .modal-content,
    html:not(.kit-squircle-off) .form-section,
    html:not(.kit-squircle-off) .form-input,
    html:not(.kit-squircle-off) .cookie-consent-banner,
    html:not(.kit-squircle-off) .dropdown-menu,
    html:not(.kit-squircle-off) .site-toast,
    html:not(.kit-squircle-off) .copy-code-btn,
    html:not(.kit-squircle-off) .form-error-message,
    html:not(.kit-squircle-off) .form-success-message,
    /* Features / home visuals pseudo */
    html:not(.kit-squircle-off) .sandbox-feature-visual::after,
    html:not(.kit-squircle-off) .bento-card-visual::after,
    /* Changelog */
    html:not(.kit-squircle-off) .changelog-version,
    html:not(.kit-squircle-off) .graph-node-content,
    html:not(.kit-squircle-off) .change-category-title,
    html:not(.kit-squircle-off) .changelog-version--magic::before,
    html:not(.kit-squircle-off) .graph-node--magic .graph-node-content::before,
    /* Modules */
    html:not(.kit-squircle-off) .module-card,
    html:not(.kit-squircle-off) .modules-table-wrapper,
    html:not(.kit-squircle-off) .modules-toolbar-search .modules-search-input,
    html:not(.kit-squircle-off) .modules-filter-icon,
    html:not(.kit-squircle-off) .modules-toolbar-reset,
    /* Download */
    html:not(.kit-squircle-off) .download-info-card,
    html:not(.kit-squircle-off) .download-hero-icon,
    html:not(.kit-squircle-off) .download-progress-track,
    /* Docs — стеклянные панели (flat sidebar без squircle) */
    html:not(.kit-squircle-off) .welcome-info-box,
    html:not(.kit-squircle-off) .welcome-article-card,
    html:not(.kit-squircle-off) .welcome-video-card,
    html:not(.kit-squircle-off) .documentation-toc,
    html:not(.kit-squircle-off) .markdown-content pre,
    html:not(.kit-squircle-off) .markdown-copy-all-btn,
    html:not(.kit-squircle-off) .exit-reading-mode-btn,
    /* About / community */
    html:not(.kit-squircle-off) .intro-card,
    html:not(.kit-squircle-off) .value-card,
    html:not(.kit-squircle-off) .mission-content,
    html:not(.kit-squircle-off) .what-we-do-item,
    html:not(.kit-squircle-off) .founders-games-channel-card,
    html:not(.kit-squircle-off) .community-group-card,
    html:not(.kit-squircle-off) .chat-info-card,
    html:not(.kit-squircle-off) .community-card,
    html:not(.kit-squircle-off) .about-card,
    /* Profile / admin */
    html:not(.kit-squircle-off) .admin-header,
    html:not(.kit-squircle-off) .admin-card,
    html:not(.kit-squircle-off) .admin-section,
    html:not(.kit-squircle-off) .stat-card,
    html:not(.kit-squircle-off) .monitoring-card,
    html:not(.kit-squircle-off) .profile-bento,
    html:not(.kit-squircle-off) .profile-skel,
    /* Legal */
    html:not(.kit-squircle-off) .legal-content,
    html:not(.kit-squircle-off) .legal-card {
        corner-shape: squircle;
    }

    /* Только feature-карточки: corner-shape на ::before безопасен вместе с их радиусом.
       НЕ применять к .gradient-border::before (кнопки / bottom-nav) — ломает mask. */
    html:not(.kit-squircle-off) .gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-article-card.gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-video-card.gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-info-box.gradient-border-feature::before {
        corner-shape: squircle;
    }

    /* Docs: перебить corner-shape: unset на TOC / welcome / code */
    html:not(.kit-squircle-off) body.page-docs .documentation-toc,
    html:not(.kit-squircle-off) body.page-docs .welcome-info-box,
    html:not(.kit-squircle-off) body.page-docs .welcome-article-card,
    html:not(.kit-squircle-off) body.page-docs .welcome-video-card,
    html:not(.kit-squircle-off) body.page-docs .markdown-content pre {
        corner-shape: squircle;
    }

    /* Крупные карточки */
    html:not(.kit-squircle-off) .kit-glass-card,
    html:not(.kit-squircle-off) .kit-glass-surface,
    html:not(.kit-squircle-off) .sandbox-feature-card,
    html:not(.kit-squircle-off) .integration-step-card,
    html:not(.kit-squircle-off) .bento-card,
    html:not(.kit-squircle-off) .faq-item,
    html:not(.kit-squircle-off) .pricing-card,
    html:not(.kit-squircle-off) .flow-card,
    html:not(.kit-squircle-off) .auth-card,
    html:not(.kit-squircle-off) .payment-return-card,
    html:not(.kit-squircle-off) .error-card,
    html:not(.kit-squircle-off) .flow-modal-card,
    html:not(.kit-squircle-off) .cookie-consent-banner,
    html:not(.kit-squircle-off) .welcome-info-box,
    html:not(.kit-squircle-off) .welcome-article-card,
    html:not(.kit-squircle-off) .welcome-video-card,
    html:not(.kit-squircle-off) .documentation-toc,
    html:not(.kit-squircle-off) .modal-content,
    html:not(.kit-squircle-off) .admin-header,
    html:not(.kit-squircle-off) .module-card,
    html:not(.kit-squircle-off) .changelog-version,
    html:not(.kit-squircle-off) .graph-node-content,
    html:not(.kit-squircle-off) .intro-card,
    html:not(.kit-squircle-off) .value-card,
    html:not(.kit-squircle-off) .mission-content,
    html:not(.kit-squircle-off) .what-we-do-item,
    html:not(.kit-squircle-off) .founders-games-channel-card,
    html:not(.kit-squircle-off) .community-group-card,
    html:not(.kit-squircle-off) .chat-info-card,
    html:not(.kit-squircle-off) .hero-banner {
        border-radius: var(--kit-squircle-lg);
    }

    /* hero / kit visual — на ПК крупнее (~60) */
    html:not(.kit-squircle-off) .kit-visual,
    html:not(.kit-squircle-off) .kit-visual-bg,
    html:not(.kit-squircle-off) .hero-visual,
    html:not(.kit-squircle-off) .hero-visual-bg,
    html:not(.kit-squircle-off) .modules-visual,
    html:not(.kit-squircle-off) .projects-visual,
    html:not(.kit-squircle-off) .cta-visual,
    html:not(.kit-squircle-off) .download-hero-visual {
        border-radius: var(--kit-squircle-xl);
    }

    html:not(.kit-squircle-off) .sandbox-feature-visual,
    html:not(.kit-squircle-off) .bento-card-visual,
    html:not(.kit-squircle-off) .integration-step-visual,
    html:not(.kit-squircle-off) .form-section,
    html:not(.kit-squircle-off) .dropdown-menu,
    html:not(.kit-squircle-off) .markdown-content pre,
    html:not(.kit-squircle-off) .download-info-card,
    html:not(.kit-squircle-off) .change-category-title {
        border-radius: var(--kit-squircle-md);
    }

    html:not(.kit-squircle-off) .kit-visual-shot,
    html:not(.kit-squircle-off) .hero-screenshot {
        border-radius: var(--kit-squircle-sm);
    }

    html:not(.kit-squircle-off) .form-input,
    html:not(.kit-squircle-off) .copy-code-btn,
    html:not(.kit-squircle-off) .markdown-copy-all-btn,
    html:not(.kit-squircle-off) .exit-reading-mode-btn,
    html:not(.kit-squircle-off) .site-toast,
    html:not(.kit-squircle-off) .modules-toolbar-search .modules-search-input,
    html:not(.kit-squircle-off) .modules-filter-icon,
    html:not(.kit-squircle-off) .modules-toolbar-reset {
        border-radius: var(--kit-squircle-sm);
    }

    html:not(.kit-squircle-off) .gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-article-card.gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-video-card.gradient-border-feature::before,
    html:not(.kit-squircle-off) .welcome-info-box.gradient-border-feature::before {
        border-radius: var(--kit-squircle-lg);
    }

    /* Мобилка: visual чуть скромнее; header / bottom-nav не трогаем */
    @media (max-width: 1023px) {
        html:not(.kit-squircle-off) .kit-visual,
        html:not(.kit-squircle-off) .kit-visual-bg,
        html:not(.kit-squircle-off) .hero-visual,
        html:not(.kit-squircle-off) .hero-visual-bg,
        html:not(.kit-squircle-off) .modules-visual,
        html:not(.kit-squircle-off) .projects-visual,
        html:not(.kit-squircle-off) .cta-visual,
        html:not(.kit-squircle-off) .download-hero-visual,
        html:not(.kit-squircle-off) .hero-banner {
            border-radius: var(--kit-squircle-md);
        }
    }
}

/* Явное выключение */
html.kit-squircle-off .kit-squircle,
html.kit-squircle-off .kit-glass-card,
html.kit-squircle-off .kit-glass-surface {
    corner-shape: initial;
}
