/* Адаптив: контейнерный запрос и четыре точки перелома.
   Часть components/forms.css; порядок частей важен — см. static/README.md. */
@container (min-width: 620px) {
    [data-search-dropdown] .search-badge--icon.search-badge--with-text {
        width: auto;
        min-width: 28px;
        max-width: 14ch;
        padding: 0 10px;
        gap: 6px;
    }

    [data-search-dropdown] .search-badge--icon.search-badge--with-text .search-badge-text {
        display: inline;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-state--loading .search-suggestion__title,
    .search-state--loading .search-suggestion__meta::before {
        animation: none;
    }

    .search-form[data-search-scope="header"] > [data-search-dropdown="header"] {
        transform: none;
        transition: none;
    }
}

@media (max-width: 900px) {
    .search-suggestion__side {
        max-width: 48%;
        gap: 4px;
    }

    [data-search-scope="header"] [data-search-results="header"] {
        max-height: max(220px, calc(var(--visual-viewport-height, 100dvh) - var(--site-header-bar-height) - var(--site-header-search-results-clearance)));
        padding-bottom: calc(var(--control-padding-x-compact) + env(safe-area-inset-bottom));
    }
}

@media (max-width: 640px) {
    .search-form[data-search-scope]:not([data-search-scope="header"]) {
        padding: 4px;
    }

    [data-search-results] {
        gap: 5px;
        padding: 6px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .search-suggestion,
    .search-suggestion__link {
        min-height: 40px;
        gap: 6px;
        padding: 6px 8px;
    }

    .search-suggestion__title {
        font-size: 13px;
        line-height: 1.3;
        -webkit-line-clamp: 1;
    }

    .search-suggestion__meta {
        font-size: 10px;
        line-height: 1.2;
        -webkit-line-clamp: 1;
    }

    .search-suggestion__meta-row .result-card__meta-badge {
        --badge-min-height: 19px;
        --badge-font-size: 9px;
    }

    .search-suggestion__side {
        max-width: none;
    }

    .search-suggestion__lang,
    .search-suggestion__badge {
        --badge-min-height: 24px;
        --badge-padding: 0 8px;
        --badge-font-size: 9px;
        max-width: 13ch;
    }
}

@media (max-width: 360px) {
    [data-search-results] {
        gap: 4px;
        padding: 4px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .search-suggestion,
    .search-suggestion__link {
        min-height: 34px;
        gap: 5px;
        padding: 6px 8px;
        grid-template-columns: 1fr;
        align-items: start;
    }

    .search-suggestion__side {
        max-width: 100%;
        justify-content: flex-start;
        margin-top: 4px;
    }

    .search-suggestion__title {
        font-size: 12px;
        line-height: 1.2;
    }

    .search-suggestion__meta {
        font-size: 9px;
        line-height: 1.15;
    }

    .search-suggestion__meta-row .result-card__meta-badge {
        --badge-min-height: 18px;
        --badge-font-size: 9px;
        --badge-padding-x: 6px;
    }

    .search-suggestion__lang,
    .search-suggestion__badge {
        max-width: 12ch;
    }

    .search-suggestion__badge.search-badge--icon {
        width: 24px;
        height: 24px;
        min-width: 24px;
        min-height: 24px;
    }

    .search-badge-icon {
        width: 12px;
        height: 12px;
    }

    .search-state {
        padding: 0 1px 6px;
    }

    .search-state .search-suggestion__title,
    .search-state .search-suggestion__meta {
        font-size: 9px;
    }

    .search-state .search-suggestion__meta {
        margin-top: 1px;
    }

    [data-search-dropdown] [data-list-divider] {
        padding: 0 1px 6px;
    }

    [data-search-dropdown] [data-list-divider-label] {
        font-size: 9px;
    }
}

/* Editor modal form: section grid and field type layout fixes.
   Uses form.editor-form--modal-compact (not .editor-page--v2) so rules apply
   both on the word page (modal) and on standalone editor pages. */

form.editor-form--modal-compact .editor-form-section__grid {
    grid-template-columns: 1fr;
    align-items: start;
}

form.editor-form--modal-compact .editor-form-section__grid .field-stack:has(> input[type="checkbox"]) {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: var(--control-height-md);
}

form.editor-form--modal-compact .editor-form-section__grid .field-stack:has(> input[type="checkbox"]) > label {
    flex: 1;
    cursor: pointer;
}

form.editor-form--modal-compact .editor-form-section__grid .field-stack:has(> input[type="checkbox"]) > input[type="checkbox"] {
    min-height: unset;
    flex: 0 0 auto;
}

form.editor-form--modal-compact .editor-form-section__grid .field-stack:has(> .file-input-group) {
    grid-column: 1 / -1;
}

/* Unified custom checkbox — applied to all checkboxes inside editor modal forms */
form.editor-form--modal-compact input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    min-height: unset;
    flex-shrink: 0;
    border: 1.5px solid var(--theme-border-control-hover);
    border-radius: 3px;
    background: var(--field-bg-color);
    cursor: pointer;
    position: relative;
    margin: 0;
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

form.editor-form--modal-compact input[type="checkbox"]:hover {
    border-color: var(--brand-color);
}

form.editor-form--modal-compact input[type="checkbox"]:focus-visible {
    border-color: var(--brand-color);
    box-shadow: var(--shadow-focus-ring-muted);
    outline: none;
}

form.editor-form--modal-compact input[type="checkbox"]:checked {
    background-color: var(--brand-color);
    border-color: var(--brand-color);
}

form.editor-form--modal-compact input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    inset: 0;
    display: block;
    background-color: var(--txt-on-accent);
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpolyline points='1,5.5 4.5,9 11,1' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpolyline points='1,5.5 4.5,9 11,1' stroke='white' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    -webkit-mask-size: 9px 8px;
    mask-size: 9px 8px;
    -webkit-mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-repeat: no-repeat;
    mask-position: center;
}
