/* =========================================================
   FIELD / ETAP 12.1-12.3 / UX + MOBILE HARDENING
   Warstwa korekt przekrojowych. Nie zastępuje CSS modułów.
   ========================================================= */

/* Elastyczne media i elementy, które najczęściej powodują poziomy scroll. */
.public-main,
.public-shell,
.container,
.field,
.account-form,
.card,
.market-form,
.loadout-form,
.gear-form,
form { min-width: 0; }

img,
picture,
video,
canvas { max-width: 100%; }

pre,
code,
.account-help,
.field__hint,
.field__error,
.account-form__errors,
.market-privacy-note { overflow-wrap: anywhere; }

.input,
.select,
.textarea,
input[type="file"] {
    min-width: 0;
    max-width: 100%;
}

input[type="file"] { overflow: hidden; }

/* Duże formularze: akcje pozostają dostępne po przewinięciu, ale nie podczas
   używania klawiatury ekranowej. Dolna nawigacja FIELD ma 64 px. */
@media (max-width: 960px) {
    body.field-app-authenticated .mobile-form-actions {
        position: sticky;
        z-index: 70;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        margin-inline: calc(-1 * var(--space-2));
        padding: .75rem var(--space-2);
        border-top: 1px solid var(--color-border);
        background: rgba(8, 10, 9, .94);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }

    /* VisualViewport w mobile-navigation.js ustawia tę klasę po otwarciu
       klawiatury. Wtedy pasek akcji wraca do normalnego flow i niczego nie zasłania. */
    body.field-mobile-keyboard-open .mobile-form-actions,
    form:focus-within .mobile-form-actions {
        position: static;
        margin-inline: 0;
        padding-inline: 0;
        border-top: 0;
        background: transparent;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

@media (max-width: 640px) {
    /* 16 px zapobiega automatycznemu zoomowi formularzy w Safari iOS. */
    .input,
    .select,
    .textarea,
    input[type="email"],
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="url"],
    input[type="search"],
    input[type="file"] {
        font-size: 16px;
    }

    .input,
    .select,
    input[type="email"],
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="url"],
    input[type="search"] {
        min-height: 46px;
    }

    .actions.mobile-form-actions,
    .gear-form-actions.mobile-form-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: .6rem;
    }

    .actions.mobile-form-actions .btn,
    .gear-form-actions.mobile-form-actions .btn {
        width: 100%;
        min-height: 46px;
    }

    .gear-form-section__head {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .market-head h1,
    .groups-head h1,
    .module-head h1 {
        overflow-wrap: anywhere;
    }
}

/* Telefon poziomo: galerie nie zajmują całych kilku ekranów wysokości,
   formularze tracą zbędny pionowy oddech, ale zachowują pełną funkcjonalność. */
@media (orientation: landscape) and (max-width: 960px) and (max-height: 520px) {
    .gear-page,
    .market-page,
    .loadouts-page,
    .account-page,
    .groups-page,
    .community-page {
        padding-top: 1.25rem;
        padding-bottom: 1.5rem;
    }

    .gear-gallery__main,
    .market-gallery__main {
        aspect-ratio: auto;
        height: min(62vh, 330px);
        min-height: 210px;
    }

    .mobile-form-actions {
        position: static !important;
        margin-inline: 0 !important;
        padding-inline: 0 !important;
        background: transparent !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-form-actions { transition: none; }
}
