/**
 * Общие стили только для узких экранов (<768px).
 * Десктоп: элементы #mobileNav* скрыты правилом min-width.
 */

@media (max-width: 767px) {
    html {
        overflow-x: hidden;
    }
    body {
        overflow-x: hidden;
    }
    [id] {
        scroll-margin-top: 5rem;
    }

    #cookieBanner {
        left: 12px !important;
        right: 12px !important;
        width: auto !important;
        max-width: none !important;
        bottom: 12px !important;
        padding: 14px 16px !important;
        gap: 10px !important;
        font-size: 13px !important;
        z-index: 999998 !important;
    }

    .company-header {
        padding: 4px 6px;
        gap: 8px;
    }
    .logo-fixed {
        height: 36px !important;
    }
    .company-name {
        font-size: 1.125rem !important;
        line-height: 1.2 !important;
    }

    .fixed-contacts {
        bottom: 16px;
        right: 12px;
        gap: 10px;
    }
    .floating-btn {
        width: 48px;
        height: 48px;
    }
    .floating-btn::after {
        display: none;
    }

    #mobileNavBackdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 100000000;
        opacity: 0;
        transition: opacity 0.2s ease;
        pointer-events: none;
    }
    #mobileNavBackdrop.is-open {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }
    #mobileNavPanel {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        width: min(20rem, 88vw);
        height: 100%;
        max-height: 100dvh;
        background: #fff;
        z-index: 100000001;
        padding: 1rem 1rem 1.5rem;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        pointer-events: none;
    }
    #mobileNavPanel.is-open {
        transform: translateX(0);
        pointer-events: auto;
    }
    #mobileNavToggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        background: #fff;
        color: #1d1d1f;
    }
    #mobileNavToggle[aria-expanded="true"] {
        background: #f3f4f6;
    }
}

@media (min-width: 768px) {
    #mobileNavBackdrop,
    #mobileNavPanel {
        display: none !important;
    }
    #mobileNavToggle {
        display: none !important;
    }

    /*
     * Футер ПК: три «невидимые» колонки одинаковой ширины.
     * Текст не выходит за границы ячейки; между колонками — фиксированный зазор.
     */
    .site-layout-footer .footer-links-grid.grid {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: 4rem;
        row-gap: 2.5rem;
        align-items: start !important;
        width: 100%;
        gap: 2.5rem 4rem !important;
    }

    .site-layout-footer .footer-links-grid .footer-col-left,
    .site-layout-footer .footer-links-grid .footer-col-center,
    .site-layout-footer .footer-links-grid .footer-col-right {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    /* Все три блока — выравнивание по левому краю ячейки */
    .site-layout-footer .footer-links-grid .footer-col-left,
    .site-layout-footer .footer-links-grid .footer-col-center,
    .site-layout-footer .footer-links-grid .footer-col-right {
        align-self: start;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        text-align: left;
    }

    .site-layout-footer .footer-links-grid .footer-col-left ul,
    .site-layout-footer .footer-links-grid .footer-col-center ul,
    .site-layout-footer .footer-links-grid .footer-col-right ul {
        width: 100%;
        max-width: 100%;
    }

    .site-layout-footer .footer-links-grid .footer-col-left > h4:first-child,
    .site-layout-footer .footer-links-grid .footer-col-center > h4:first-child,
    .site-layout-footer .footer-links-grid .footer-col-right > h4:first-child {
        margin-top: 0;
    }

    /*
     * 2-й блок «Поддержка»: отступ текста 1 см.
     * Вернуть: --footer-col-text-indent: 0;
     */
    .site-layout-footer .footer-col-center {
        --footer-col-text-indent: 1cm;
    }

    .site-layout-footer .footer-col-center > h4,
    .site-layout-footer .footer-col-center > ul {
        padding-left: var(--footer-col-text-indent);
        box-sizing: border-box;
        width: 100%;
    }

    /*
     * 3-й блок «Контакты»: +0,5 см весь блок (иконки и текст), текст ещё +1 см внутри.
     * Итого текст с края колонки: block-shift + text-indent (0,7 + 1 = 1,7 см).
     * Вернуть: --footer-contacts-block-shift: 0; --footer-contacts-text-indent: 0;
     */
    .site-layout-footer .footer-contacts-body {
        --footer-contacts-block-shift: 0.7cm;
        --footer-contacts-text-indent: 1cm;
        padding-left: var(--footer-contacts-block-shift);
        box-sizing: border-box;
    }

    .site-layout-footer .footer-contacts-body > h4 {
        padding-left: var(--footer-contacts-text-indent);
        box-sizing: border-box;
        width: 100%;
    }

    .site-layout-footer .footer-contacts-body > div.space-y-3 {
        align-items: flex-start !important;
        width: 100%;
    }

    .site-layout-footer .footer-contacts-body a.flex.items-center,
    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 {
        display: grid !important;
        grid-template-columns: var(--footer-contacts-text-indent) minmax(0, 1fr);
        gap: 0 !important;
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
        text-align: left;
    }

    .site-layout-footer .footer-contacts-body a.flex.items-center {
        align-items: center;
    }

    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 {
        align-items: start;
    }

    .site-layout-footer .footer-contacts-body a.flex.items-center > span:first-child,
    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 > span:first-child {
        justify-self: start;
    }

    .site-layout-footer .footer-contacts-body .footer-address-lines {
        display: block;
        line-height: 1.45;
    }

    .site-layout-footer .footer-contacts-body .footer-social {
        padding-left: var(--footer-contacts-text-indent);
        margin-top: 1.5rem;
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        justify-content: flex-start;
    }

    .site-layout-footer .footer-legal-nav {
        margin-top: 0.75rem !important;
        padding-top: 1rem !important;
        width: 100%;
    }

    .site-layout-footer .site-layout-footer__bottom {
        border-top-color: #e5e7eb !important;
    }
}

/* Общий футер: серая линия сверху (видна и на белом фоне ЛК) */
.site-layout-footer {
    border-top: 1px solid #d1d5db !important;
}

.site-layout-footer > .max-w-5xl.mx-auto,
.site-layout-footer > .site-layout-footer__bottom {
    width: 100%;
    max-width: 64rem;
    box-sizing: border-box;
}

/* Единый цвет правовых ссылок (главная = ЛК) */
.site-layout-footer .footer-legal-nav a {
    color: #1d4ed8 !important;
    font-weight: 500 !important;
    text-decoration: underline !important;
    text-underline-offset: 2px !important;
    text-decoration-color: rgb(37 99 235 / 0.5) !important;
}

.site-layout-footer .footer-legal-nav a:hover {
    color: #1e3a8a !important;
}

/*
 * Футер мобилка: отступы как в Word — текст/заголовки 1 см, иконки контактов 0,5 см от левого края.
 * ПК: только @media (min-width: 768px) выше, этот блок не применяется.
 */
@media (max-width: 767px) {
    .site-layout-footer {
        --footer-m-text-indent: 1.4cm;
        --footer-m-icon-indent: 0.5cm;
        --footer-m-icon-col: calc(var(--footer-m-text-indent) - var(--footer-m-icon-indent));
        padding-left: env(safe-area-inset-left, 0px) !important;
        padding-right: max(24px, env(safe-area-inset-right, 0px)) !important;
    }

    .site-layout-footer .footer-links-grid {
        padding-left: 0;
        padding-right: 0;
        box-sizing: border-box;
        width: 100%;
    }

    .site-layout-footer .footer-links-grid .footer-col-left,
    .site-layout-footer .footer-links-grid .footer-col-center,
    .site-layout-footer .footer-links-grid .footer-col-right.footer-contacts-body {
        padding-left: 0 !important;
        box-sizing: border-box;
        width: 100%;
        align-items: flex-start !important;
        text-align: left !important;
    }

    /* Блоки 1–2: заголовки и пункты списка — 1 см */
    .site-layout-footer .footer-links-grid .footer-col-left > h4,
    .site-layout-footer .footer-links-grid .footer-col-center > h4,
    .site-layout-footer .footer-links-grid .footer-col-left > ul,
    .site-layout-footer .footer-links-grid .footer-col-center > ul {
        padding-left: var(--footer-m-text-indent) !important;
        margin-left: 0 !important;
        box-sizing: border-box;
        width: 100%;
        text-align: left !important;
    }

    .site-layout-footer .footer-links-grid .footer-col-left > h4,
    .site-layout-footer .footer-links-grid .footer-col-center > h4,
    .site-layout-footer .footer-contacts-body > h4 {
        margin-top: 0 !important;
        margin-bottom: 1.5rem !important;
    }

    /* Блок 3: заголовок — 1 см */
    .site-layout-footer .footer-contacts-body > h4 {
        padding-left: var(--footer-m-text-indent) !important;
        box-sizing: border-box;
        width: 100%;
        text-align: left !important;
    }

    .site-layout-footer .footer-contacts-body > div.space-y-3 {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        row-gap: 12px !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
    }

    .site-layout-footer .footer-contacts-body > div.space-y-3 > * {
        margin: 0 !important;
        margin-block-start: 0 !important;
        margin-block-end: 0 !important;
    }

    /* Строки контактов: иконка 0,5 см, текст с 1 см */
    .site-layout-footer .footer-contacts-body a.flex.items-center,
    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 {
        display: grid !important;
        grid-template-columns: var(--footer-m-icon-col) minmax(0, 1fr) !important;
        gap: 0 !important;
        padding-left: var(--footer-m-icon-indent) !important;
        margin: 0 !important;
        line-height: 1.25 !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        text-align: left !important;
    }

    .site-layout-footer .footer-contacts-body a.flex.items-center {
        align-items: center !important;
    }

    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 {
        align-items: start !important;
        line-height: 1.35 !important;
    }

    .site-layout-footer .footer-contacts-body .flex.items-start.gap-3 > span:first-child,
    .site-layout-footer .footer-contacts-body a.flex.items-center > span:first-child {
        margin: 0 !important;
        justify-self: start;
        flex-shrink: 0;
    }

    .site-layout-footer .footer-contacts-body .footer-address-lines {
        line-height: 1.35 !important;
    }

    /* Социконки — 1 см, как текст */
    .site-layout-footer .footer-col-right .footer-social {
        padding-left: var(--footer-m-text-indent) !important;
        margin-top: 12px !important;
        margin-block-start: 12px !important;
        justify-content: flex-start !important;
    }

    /* Правовые ссылки и copyright — 1 см */
    .site-layout-footer .footer-legal-nav {
        padding-left: var(--footer-m-text-indent) !important;
        box-sizing: border-box;
        width: 100%;
        text-align: left !important;
    }

    .site-layout-footer .site-layout-footer__bottom > .flex,
    .site-layout-footer .site-layout-footer__bottom > div {
        padding-left: var(--footer-m-text-indent);
        box-sizing: border-box;
        text-align: left;
    }

    /*
     * Мобилка + iOS (Chrome на iPhone): читаемая типографика после output.css.
     */
    html {
        -webkit-font-smoothing: auto;
    }

    html,
    body,
    button,
    input,
    select,
    textarea,
    p,
    li,
    span,
    a,
    label {
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
        font-synthesis: weight style;
    }

    body {
        opacity: 1 !important;
        color: #1d1d1f !important;
        font-weight: 500 !important;
    }

    .font-normal { font-weight: 500 !important; }
    .font-medium { font-weight: 550 !important; }
    .font-semibold { font-weight: 600 !important; }
    .font-bold { font-weight: 700 !important; }

    .text-gray-300 { color: #6b7280 !important; font-weight: 500 !important; }
    .text-gray-400 { color: #374151 !important; font-weight: 600 !important; }
    .text-gray-500 { color: #1f2937 !important; font-weight: 500 !important; }
    .text-gray-600 { color: #111827 !important; font-weight: 500 !important; }
    .text-gray-700 { color: #0f172a !important; font-weight: 500 !important; }

    label.text-gray-400,
    .text-xs.font-bold.text-gray-400 {
        color: #1f2937 !important;
        font-weight: 700 !important;
    }

    .site-layout-footer .footer-links-grid ul,
    .site-layout-footer .footer-links-grid a {
        color: #1f2937 !important;
        font-weight: 500 !important;
    }

    .reveal,
    .reveal.active {
        opacity: 1 !important;
    }
}

/* iOS (Chrome + Safari): класс sigma-ios из js/mobile-legible.js */
html.sigma-ios .site-layout-footer .footer-links-grid ul,
html.sigma-ios .site-layout-footer .footer-links-grid a {
    color: #1f2937 !important;
    font-weight: 500 !important;
}

html.sigma-ios label.text-gray-400,
html.sigma-ios .text-xs.font-bold.text-gray-400 {
    color: #1f2937 !important;
    font-weight: 700 !important;
}
