/* Overrides for style.css: tablet/iPad + scroll-snap conflicts */

html {
    scroll-snap-type: none !important;
    scroll-behavior: auto;
    height: auto !important;
    overscroll-behavior-y: auto !important;
    overflow-x: clip;
    max-width: 100%;
}

body {
    overflow-x: clip;
    max-width: 100%;
}

/* --- Homepage: fluid sections (все экраны, не только mobile) --- */
html.site-home .screen {
    scroll-snap-align: none !important;
    scroll-snap-stop: normal !important;
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: 100%;
    overflow-x: clip !important;
    overflow-y: visible !important;
}

html.site-home .screen-inner {
    position: relative !important;
    z-index: 2;
    max-width: 100%;
    min-width: 0;
}

html.site-home .screen-footer {
    position: static !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: 120px !important;
    margin-top: 20px !important;
    bottom: auto !important;
    object-fit: cover !important;
    opacity: 1 !important;
    pointer-events: none;
}

html.site-home .scroll-card,
html.site-home .faq-card,
html.site-home .requisites-scroll,
html.site-home .icon-cabinet,
html.site-home .testimonial-grid {
    max-height: none !important;
    overflow: visible !important;
}

/* Главная: sticky-кнопка не перекрывает футер */
html.site-home main.snap-root {
    padding-bottom: 0;
    max-width: 100%;
    overflow-x: clip;
}

html.site-home .site-footer {
    padding-bottom: calc(88px + env(safe-area-inset-bottom)) !important;
    padding-top: 24px !important;
    margin-top: 0 !important;
    border-top: none !important;
}

html.site-home .sticky-cta {
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

html.site-home .sticky-cta.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Возвращаем docs-логику: пролистывание по блокам на desktop */
@media (min-width: 981px) {
    html.site-home {
        /* scroll-snap-type: y mandatory !important; */
        /* scroll-behavior: smooth !important; */
        height: 100% !important;
        overscroll-behavior-y: contain !important;
    }

    html.site-home body {
        min-height: 100% !important;
    }

    html.site-home .screen {
        min-height: 100svh !important;
        height: 100svh !important;
        /* scroll-snap-align: start !important; */
        /* scroll-snap-stop: always !important; */
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        overflow: hidden !important;
    }

    html.site-home .screen-footer {
        position: absolute !important;
        left: 0;
        right: 0;
        bottom: 0 !important;
        margin: 0 !important;
    }

    html.site-home #loan .hero-inner {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    html.site-home #loan .calculator {
        margin-bottom: 0 !important;
    }

    /* Contacts is content-heavy: keep it above footer */
    html.site-home #contacts.screen {
        height: auto !important;
        min-height: 100svh !important;
        align-items: flex-start !important;
        overflow: visible !important;
        padding-bottom: 0 !important;
    }

    html.site-home #contacts .screen-inner {
        padding-bottom: 24px;
    }

    html.site-home #contacts .final-calc-reminder {
        position: relative;
        z-index: 3;
    }
}

/* Секция «О компании»: картинка вплотную к футеру */
html.site-home #contacts.screen {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

#contacts .final-calc-reminder {
    margin-bottom: 16px;
}

html.site-home #contacts .screen-footer {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: min(160px, 20vw) !important;
    margin-top: 4px !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
    line-height: 0 !important;
    object-fit: cover !important;
    object-position: center bottom !important;
    vertical-align: bottom !important;
}

@media (min-width: 981px) {
    html.site-home #contacts .requisites-scroll {
        max-height: none !important;
        overflow: visible !important;
    }
}

/*
 * Tablet + iPad (до 1024px включительно):
 * iPad landscape = 1024px попадал в desktop (981px+) — ломалась вёрстка
 */
@media (max-width: 1024px) {
    /* Header: бургер вместо desktop-nav */
    .desktop-nav {
        display: none !important;
    }

    .burger {
        display: flex !important;
    }

    .site-header {
        width: calc(100% - 28px) !important;
        height: 60px !important;
        padding: 0 14px !important;
    }

    .brand img {
        height: 32px !important;
    }

    /* Homepage */
    html.site-home main.snap-root {
        padding-bottom: 0;
    }

    html.site-home .screen {
        display: block !important;
        min-height: 0 !important;
        height: auto !important;
        align-items: stretch !important;
        overflow: visible !important;
        padding: 88px 0 28px !important;
    }

    html.site-home #contacts.screen {
        padding-bottom: 0 !important;
    }

    html.site-home .screen:before {
        display: none !important;
    }

    html.site-home .screen-inner {
        position: relative !important;
        z-index: 2 !important;
        width: calc(100% - 32px) !important;
        margin: 0 auto !important;
    }

    html.site-home .top-art,
    html.site-home .hero-art,
    .top-art,
    .hero-art {
        position: static !important;
        display: block !important;
        width: min(240px, 40vw) !important;
        height: auto !important;
        max-height: 160px !important;
        margin: 0 auto 16px !important;
        object-fit: contain !important;
        filter: none !important;
        opacity: 1 !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
    }

    html.site-home .hero-copy,
    html.site-home .section-title,
    .hero-copy,
    .section-title {
        padding-right: 0 !important;
        max-width: none !important;
    }

    html.site-home .hero-copy h1,
    html.site-home .section-title h2,
    .hero-copy h1,
    .section-title h2 {
        font-size: clamp(32px, 5.5vw, 48px) !important;
        line-height: 1.05 !important;
        max-width: none !important;
    }

    html.site-home .hero-copy p,
    html.site-home .section-title p,
    .hero-copy p,
    .section-title p {
        font-size: clamp(16px, 2.2vw, 20px) !important;
        max-width: none !important;
    }

    html.site-home .screen-footer {
        position: static !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        max-height: 72px !important;
        margin-top: 18px !important;
        bottom: auto !important;
        object-fit: cover !important;
        opacity: 1 !important;
    }

    html.site-home .calculator,
    #loan .calculator {
        width: 100% !important;
        max-width: none !important;
        margin-top: 16px !important;
        padding: 18px !important;
    }

    #loan .return-box {
        grid-template-columns: 1fr 1fr !important;
    }

    #loan .return-box .return-badges {
        grid-column: 1 / -1 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        border-left: 0 !important;
        border-top: 1px solid var(--line) !important;
        padding: 12px 14px !important;
    }

    #loan .return-badges span {
        flex: 1 1 auto !important;
        width: auto !important;
        white-space: normal !important;
        padding: 6px 10px !important;
        background: #eef7ff !important;
        border-radius: 12px !important;
        font-size: 12px !important;
    }

    .compact-grid,
    .steps-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        margin-top: 14px !important;
    }

    .compact-grid article,
    .steps-grid article,
    .trust-list article,
    .proof-grid article,
    .icon-cabinet div {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    .trust-list,
    .proof-grid {
        grid-template-columns: 1fr !important;
    }

    .cabinet-board,
    .icon-cabinet {
        grid-template-columns: repeat(2, 1fr) !important;
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .scroll-card,
    .faq-card,
    .requisites-scroll,
    .testimonial-grid,
    #faq .faq-card,
    #faq .faq-proof,
    #documents .doc-buttons,
    #documents .documents-panel,
    #contacts .requisites-scroll,
    #contacts .final-calc-reminder {
        max-height: none !important;
        overflow: visible !important;
        width: 100% !important;
        max-width: none !important;
    }

    .section-title h2,
    .section-title p {
        max-width: none !important;
    }

    html.site-home .icon-steps article {
        min-height: 0 !important;
        overflow: visible !important;
    }

    html.site-home .footer-screen {
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        padding: 80px 0 0 !important;
    }

    /* Sticky CTA */
    .sticky-cta {
        left: 18px !important;
        right: 18px !important;
        transform: none !important;
        width: auto !important;
        bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    }

    /* Portal pages */
    .portal-main {
        width: calc(100% - 32px) !important;
        padding: 96px 0 48px !important;
    }

    .portal-hero {
        padding: 24px !important;
        border-radius: 28px !important;
    }

    .portal-hero h1 {
        font-size: clamp(34px, 5vw, 52px) !important;
    }

    .portal-hero p {
        font-size: clamp(16px, 2vw, 20px) !important;
    }

    .portal-grid.two,
    .portal-grid.three {
        grid-template-columns: 1fr !important;
    }

    .portal-card {
        padding: 20px !important;
    }

    .portal-card h2 {
        font-size: 24px !important;
    }

    .process-list {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .feedback-form {
        grid-template-columns: 1fr !important;
    }

    .documents-grid,
    .local-documents-grid {
        grid-template-columns: 1fr !important;
    }

    /* Footer */
    .footer-inner {
        grid-template-columns: 1fr !important;
    }

    .footer-groups {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    html.site-home .site-footer {
        padding: 32px 16px calc(88px + env(safe-area-inset-bottom)) !important;
    }
}

/* iPad / tablet only: 2 колонки (не на телефонах и Galaxy Fold) */
@media (min-width: 768px) and (max-width: 1024px) {
    #faq.screen,
    #documents.screen,
    #contacts.screen {
        display: grid !important;
        grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
        column-gap: 20px;
        row-gap: 16px;
        align-items: start !important;
        padding: 88px 20px 28px !important;
    }

    #faq .top-art,
    #documents .top-art,
    #contacts .top-art {
        grid-column: 1;
        grid-row: 1;
        margin: 0 !important;
        width: 100% !important;
        max-height: 200px !important;
        align-self: center;
    }

    #faq .screen-inner,
    #documents .screen-inner,
    #contacts .screen-inner {
        grid-column: 2;
        grid-row: 1;
        width: 100% !important;
        margin: 0 !important;
    }

    #faq .screen-footer,
    #documents .screen-footer,
    #contacts .screen-footer {
        grid-column: 1 / -1;
        grid-row: 2;
        max-height: 80px !important;
        margin-top: 8px !important;
    }

    html.site-home #contacts .screen-footer {
        max-height: min(140px, 22vw) !important;
        height: auto !important;
        margin-bottom: 0 !important;
    }

    html.site-home #contacts.screen {
        padding-bottom: 0 !important;
    }

    #faq .faq-card summary {
        font-size: clamp(17px, 2vw, 21px) !important;
        padding: 16px 4px !important;
    }

    #faq .faq-card p {
        font-size: clamp(15px, 1.8vw, 17px) !important;
    }

    #faq .faq-proof {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 16px !important;
        margin-top: 16px !important;
        padding: 18px 20px !important;
    }

    #faq .faq-proof-head b {
        font-size: clamp(32px, 4vw, 40px) !important;
    }

    #faq .faq-proof-head span {
        font-size: clamp(16px, 2vw, 20px) !important;
    }
}

/* Телефоны + Galaxy Z Fold (до 767px) */
@media (max-width: 767px) {
    html.site-home .top-art,
    html.site-home .hero-art,
    .top-art,
    .hero-art {
        position: static !important;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        max-width: 100% !important;
    }

    html.site-home .compact-grid,
    html.site-home .steps-grid,
    html.site-home .cabinet-board,
    html.site-home .icon-cabinet {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    html.site-home .compact-grid article,
    html.site-home .steps-grid article,
    html.site-home .trust-list article,
    html.site-home .proof-grid article,
    html.site-home .icon-cabinet div,
    html.site-home .notice,
    html.site-home .section-title {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    html.site-home .sticky-cta {
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        transform: none !important;
    }

    #faq.screen,
    #documents.screen,
    #contacts.screen {
        display: block !important;
        padding: 84px 0 24px !important;
    }

    html.site-home #contacts.screen {
        padding-bottom: 0 !important;
    }

    html.site-home #contacts .screen-footer {
        max-height: min(120px, 34vw) !important;
        height: auto !important;
        margin-bottom: 0 !important;
    }

    #faq .top-art,
    #documents .top-art,
    #contacts .top-art {
        display: block !important;
        position: static !important;
        width: min(160px, 46vw) !important;
        max-height: 120px !important;
        margin: 0 auto 12px !important;
    }

    #faq .screen-inner,
    #documents .screen-inner,
    #contacts .screen-inner {
        display: block !important;
        width: calc(100% - 28px) !important;
        max-width: none !important;
        margin: 0 auto !important;
    }

    #faq .section-title,
    #faq .faq-card,
    #faq .faq-proof {
        width: 100% !important;
        max-width: none !important;
    }

    #faq .faq-proof {
        display: block !important;
        padding: 14px 16px !important;
    }

    #faq .faq-proof-head b {
        font-size: 28px !important;
    }

    #faq .faq-proof-head span {
        font-size: 15px !important;
    }

    .section-title,
    .hero-copy {
        padding-right: 0 !important;
        max-width: none !important;
        width: 100% !important;
    }

    .section-title h2 {
        font-size: clamp(28px, 8vw, 36px) !important;
    }

    .section-title p {
        font-size: 15px !important;
    }
}

/* iPad portrait / small tablet tweaks */
@media (max-width: 820px) {
    html.site-home .screen-inner,
    .portal-main {
        width: calc(100% - 28px) !important;
    }

    .portal-hero h1 {
        font-size: clamp(32px, 6vw, 44px) !important;
    }

    #loan .return-box {
        grid-template-columns: 1fr !important;
    }
}

/* Phone (legacy breakpoint) */
@media (max-width: 640px) {
    html.site-home .screen {
        padding: 84px 0 24px !important;
    }

    html.site-home .top-art,
    html.site-home .hero-art,
    .top-art,
    .hero-art {
        width: min(180px, 48vw) !important;
        max-height: 120px !important;
        margin-bottom: 12px !important;
    }

    html.site-home .screen-footer {
        max-height: 56px !important;
        margin-top: 14px !important;
    }

    .site-header {
        width: calc(100% - 20px) !important;
        height: 56px !important;
        top: 10px !important;
        border-radius: 20px !important;
    }

    .portal-main {
        width: calc(100% - 28px) !important;
        padding: 88px 0 42px !important;
    }

    .portal-hero {
        padding: 20px !important;
        border-radius: 24px !important;
    }

    .portal-hero h1 {
        font-size: 34px !important;
    }

    .portal-hero p {
        font-size: 16px !important;
    }

    .portal-card {
        padding: 16px !important;
        border-radius: 22px !important;
    }

    .portal-card h2 {
        font-size: 22px !important;
    }

    .portal-card p,
    .portal-list li {
        font-size: 15px !important;
    }

    .process-list {
        grid-template-columns: 1fr !important;
    }

    .footer-groups {
        grid-template-columns: 1fr !important;
    }

    .portal-actions {
        flex-direction: column;
    }

    .portal-actions .primary-action,
    .portal-actions .secondary-action {
        width: 100%;
        justify-content: center;
    }
}

/* Short laptop screens */
@media (min-width: 1025px) and (max-height: 900px) {
    html.site-home .screen {
        height: 100svh !important;
        min-height: 100svh !important;
        overflow: hidden !important;
    }

    html.site-home #contacts.screen {
        min-height: 0 !important;
    }

    html.site-home .scroll-card,
    html.site-home .faq-card,
    html.site-home .requisites-scroll,
    html.site-home .icon-cabinet,
    html.site-home .testimonial-grid {
        max-height: none !important;
        overflow: visible !important;
    }
}
