/* Mobile layout — kvach.ru */

@media (max-width: 1023px) {
    .site-nav-cta#settings-open {
        display: none !important;
    }

    .site-nav-toggle {
        margin-left: auto;
    }
}

@media (max-width: 767px) {
    html {
        -webkit-text-size-adjust: 100%;
    }

    body {
        cursor: auto;
    }

    .px-grid-margin {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .py-section-gap {
        padding-top: 4rem !important;
        padding-bottom: 4rem !important;
    }

    .gap-element-gap {
        gap: 1.5rem !important;
    }

    /* Header */
    .site-nav-bar {
        padding: 0.75rem 16px;
        gap: 0.75rem;
    }

    .site-logo {
        font-size: 1.125rem;
    }

    /* Hero */
    .hero-viewport {
        min-height: calc(100dvh - 4.25rem);
        height: calc(100dvh - 4.25rem) !important;
        overflow: hidden;
    }

    .hero-viewport > .relative.z-10 {
        min-height: 100%;
        padding-top: 0;
        padding-bottom: 0;
    }

    .hero-viewport .flex.items-center.justify-center {
        align-items: center;
        padding-top: 0;
    }

    .hero-title.text-hero-display {
        font-size: clamp(2.125rem, 10.5vw, 3.25rem) !important;
        line-height: 1.05 !important;
        margin-bottom: 1.25rem !important;
        letter-spacing: 0.04em;
    }

    .hero-title-word + .hero-title-word {
        display: block;
        margin-left: 0;
        margin-top: 0.08em;
    }

    .hero-typewriter {
        white-space: normal !important;
        height: auto !important;
        min-height: 2.6em;
        padding: 0 0.25rem;
        margin-bottom: 1.5rem !important;
        line-height: 1.35;
        font-size: clamp(0.8125rem, 3.4vw, 1rem) !important;
        text-wrap: balance;
    }

    .hero-viewport [data-i18n-html="hero.status"] {
        font-size: 0.6875rem !important;
        letter-spacing: 0.08em !important;
        line-height: 1.45;
        margin-bottom: 1.75rem !important;
        padding: 0 0.5rem;
    }

    .hero-viewport .flex.flex-col.md\:flex-row {
        width: 100%;
        max-width: 22rem;
        margin: 0 auto;
        gap: 0.75rem !important;
    }

    .hero-viewport .scanning-btn {
        width: 100%;
        padding-left: 1.25rem !important;
        padding-right: 1.25rem !important;
        font-size: 13px !important;
        text-align: center;
    }

    #new-easter-egg {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        margin-top: 1.5rem;
        padding: 0 0.5rem;
    }

    #new-easter-egg .font-quote-italic {
        font-size: 0.8125rem !important;
        line-height: 1.45;
    }

    /* Section dividers */
    .section-divider {
        padding: 1.75rem 16px;
        gap: 0.5rem;
    }

    .section-divider-core {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
        max-width: 100%;
    }

    .section-divider-label {
        white-space: normal;
        text-align: center;
        letter-spacing: 0.12em;
        line-height: 1.35;
        max-width: 11rem;
    }

    .section-divider-tick {
        display: none;
    }

    /* Stats */
    .stats-section {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }

    .stats-grid {
        gap: 1.5rem 1rem;
    }

    .stat-label,
    .stat-hover-caption {
        white-space: normal;
    }

    .stat-label-wrap {
        min-height: auto;
    }

    .stat-counter {
        font-size: clamp(2rem, 9vw, 2.75rem);
    }

    /* Cards & expertise */
    .spec-card {
        padding: 1.5rem !important;
    }

    .quote-card,
    .glass-card {
        padding: 1.5rem !important;
    }

    .spec-subtitle {
        font-size: 0.875rem;
        line-height: 1.45;
    }

    /* Timeline */
    .timeline-entry {
        margin-bottom: 2.5rem !important;
    }

    .timeline-entry .font-headline-h2.text-2xl {
        font-size: 1.375rem !important;
    }

    /* Portfolio */
    .portfolio-grid .glass-card {
        padding: 1.5rem !important;
        min-height: auto !important;
    }

    .portfolio-grid .font-headline-h2.text-3xl {
        font-size: 1.5rem !important;
        line-height: 1.2;
    }

    .portfolio-grid .flex.gap-3.mb-6 {
        flex-wrap: wrap;
    }

    .portfolio-card-footer {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.875rem;
    }

    .portfolio-card-footer .font-code-accent {
        line-height: 1.4;
        word-break: break-word;
    }

    .portfolio-card-footer .scanning-btn {
        width: 100%;
        justify-content: center;
    }

    /* Dossier */
    .dossier-panel {
        padding: 1.25rem 1rem 1.5rem !important;
    }

    .dossier-meta-row {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.125rem 0.375rem;
        line-height: 1.5;
    }

    .dossier-meta-dots {
        display: none;
    }

    .dossier-meta-row span:last-child {
        flex-shrink: 1;
        flex-basis: 100%;
        word-break: break-word;
        padding-left: 0;
    }

    .dossier-body {
        font-size: 15px;
    }

    /* Contact */
    .contact-section .font-headline-h2 {
        font-size: clamp(1.75rem, 7vw, 2.25rem) !important;
    }

    .contact-panel {
        padding: 1.25rem !important;
    }

    .contact-channel-value {
        font-size: 0.9375rem;
        word-break: break-word;
    }

    /* Settings — bottom sheet */
    .settings-panel {
        top: auto !important;
        right: 0 !important;
        left: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: min(88dvh, 640px);
        overflow-y: auto;
        border-radius: 1rem 1rem 0 0;
        transform-origin: bottom center !important;
    }

    .settings-overlay.is-open .settings-panel {
        transform: translateY(0) scale(1) !important;
        animation: mobile-sheet-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes mobile-sheet-in {
        from { transform: translateY(100%); opacity: 0.6; }
        to { transform: translateY(0); opacity: 1; }
    }

    /* Footer */
    .site-footer-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .site-footer-nav {
        flex-wrap: wrap;
        gap: 0.75rem 1rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .stat-item {
        text-align: center;
    }

    .stat-label-wrap {
        justify-content: center;
    }
}

/* Legal pages */
@media (max-width: 767px) {
    html,
    body,
    body.legal-page {
        max-width: 100%;
        overflow-x: hidden;
    }

    body.legal-page * {
        min-width: 0;
        box-sizing: border-box;
    }

    body.legal-page .legal-hero-inner {
        padding: 2rem 16px 1.5rem;
    }

    .legal-title {
        font-size: clamp(1.75rem, 8vw, 2.25rem);
        line-height: 1.15;
    }

    .legal-effective {
        font-size: 0.875rem;
        line-height: 1.45;
    }

    .legal-divider {
        padding: 1.25rem 16px;
    }

    .legal-divider-label {
        white-space: normal;
        text-align: center;
        letter-spacing: 0.12em;
        line-height: 1.35;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .legal-toc-wrap,
    .legal-sections,
    .legal-footnote-wrap,
    .ip-download-wrap {
        padding-left: 16px;
        padding-right: 16px;
    }

    .legal-section-card {
        padding: 1rem !important;
    }

    .legal-section-body {
        font-size: 16px;
        line-height: 1.65;
    }

    .legal-section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.375rem;
    }

    .ip-download-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.875rem;
    }

    .ip-download-actions {
        width: 100%;
    }

    .ip-download-btn {
        flex: 1;
        text-align: center;
        justify-content: center;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .legal-toc {
        width: 100%;
    }

    .legal-toc-link {
        max-width: 100%;
        white-space: normal;
        line-height: 1.35;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    body.legal-page.ip-page .ip-id-strip {
        gap: 0.5rem;
    }

    body.legal-page.ip-page .ip-id-chip {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body.legal-page.ip-page .ip-meta-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.375rem;
    }

    body.legal-page.ip-page .ip-meta-label,
    body.legal-page.ip-page .ip-meta-row > span:first-child,
    body.legal-page.ip-page .ip-meta-grid--cols .ip-meta-label {
        width: auto;
        max-width: 100%;
    }

    body.legal-page.ip-page .ip-meta-value,
    body.legal-page.ip-page .ip-meta-grid--cols .ip-meta-value {
        justify-content: flex-start;
        text-align: left;
    }

    body.legal-page.ip-page .ip-meta-value > span,
    body.legal-page.ip-page .ip-meta-value > a {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    main,
    section,
    .legal-main {
        max-width: 100%;
        overflow-x: clip;
    }

    img,
    video {
        max-width: 100%;
        height: auto;
    }
}

@media (pointer: fine) and (min-width: 768px) {
    body.has-custom-cursor {
        cursor: none;
    }
}
