/* FFV (org 61) phone layout, linked by _OrgCustomCss for org 61 only. Below Bootstrap's md
   breakpoint it replaces the nested .forms-wrapper/.form-body scroll boxes of sitev2.css
   with one page scroll and a fixed action bar. Desktop widths and markup are unchanged. */
@media (max-width: 767.98px) {

    html {
        zoom: 1;
        font-size: 15px;
        overflow-x: hidden;
        scroll-padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }

    body {
        height: auto;
        min-height: 100%;
        overflow: visible;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    /* FFVReceipt has no action bar. Without :has() support the bar's room stays, which is harmless */
    body:not(:has(.buttonsBar)) {
        padding-bottom: 16px;
    }

    #_orgBg {
        position: fixed !important;
    }

    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-button {
        display: none;
    }

    .steps {
        width: auto;
        max-width: none;
        min-height: 0;
        max-height: none;
        margin: 0 12px;
        padding: 12px 0 32px;
    }

    .steps .steps-container {
        display: flex;
        gap: 4px;
        height: auto;
        background: none;
        counter-reset: ffv-step;
    }

    .steps .steps-container li {
        float: none;
        flex: 1 1 0;
        width: auto !important;
        counter-increment: ffv-step;
    }

    .steps .steps-container li .step .step-image {
        margin: 0;
    }

    .steps .steps-container li .step .step-image span {
        width: 100%;
        height: 6px;
        border-radius: 3px;
        background-color: #87949b;
    }

    .steps .steps-container li .step .step-image span::after {
        display: none !important;
    }

    .steps .steps-container li:has(~ li.activated) .step .step-image span,
    .steps .steps-container li.activated .step .step-image span {
        background-color: #2a323f;
    }

    .steps .steps-container li .step .step-description p {
        display: none;
    }

    .steps .steps-container li.activated .step .step-description p {
        display: block;
        position: absolute;
        left: 0;
        top: 26px;
        margin: 0;
        padding: 1px 10px;
        font-size: .85rem;
        white-space: nowrap;
    }

    .steps .steps-container li.activated .step .step-description p::before {
        content: "Steg " counter(ffv-step) " \00B7  ";
        font-weight: 400;
    }

    .steps .step-bar {
        display: none;
    }

    #appBox {
        width: auto;
        max-width: none;
        height: auto;
        margin: 0 8px 12px;
        border-color: #c9d3d9;
        border-radius: 12px;
    }

    .container-forms {
        width: 100%;
        height: auto;
    }

    #personForms {
        margin-bottom: 0;
    }

    .form-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin: 0;
        max-height: none;
        padding: 12px 14px;
        border-bottom: 1px solid #e1e7ea;
    }

    .form-header .formLogo {
        position: static;
        float: none;
        flex: none;
        height: 52px;
        width: auto;
        padding: 0;
    }

    h3.display-4 {
        max-width: none;
        margin: 0;
        font-size: 1.3rem;
        line-height: 1.25;
    }

    /* site.js setWrapperHeight() keeps writing an inline height on resize */
    .forms-wrapper {
        height: auto !important;
        overflow: visible;
        margin: 0;
        padding: 0;
    }

    .form-body {
        display: flow-root;
        width: auto;
        height: auto !important;
        overflow: visible;
        padding: 16px 14px 4px;
    }

    .form-body h3 {
        font-size: 1.35rem;
        margin-bottom: .35rem;
    }

    .form-body .titleSpace h3 {
        margin: 0 0 .4rem;
        padding-top: .9rem;
        border-top: 1px solid #e1e7ea;
        font-size: 1.1rem;
        font-weight: 600;
    }

    .form-body p {
        font-size: .93rem;
    }

    .form-body p:has(> i.info) {
        padding: 10px 12px;
        border-radius: 8px;
        background: #e8f5f8;
    }

    .form-group {
        margin-bottom: .8rem;
    }

    .form-group label {
        margin-bottom: .2rem;
        font-size: .9rem;
    }

    /* Below 16px iOS Safari zooms the page in when a field gets focus */
    .form-control,
    .custom-file,
    .custom-file-input,
    .custom-file-label {
        height: calc(1.5em + 1.25rem + 2px);
        font-size: 16px;
    }

    .custom-file-label,
    .custom-file-label::after {
        padding-top: .625rem;
        padding-bottom: .625rem;
    }

    .custom-file-label::after {
        height: calc(1.5em + 1.25rem);
    }

    textarea.form-control {
        height: auto;
    }

    .form-row > .form-group:empty {
        display: none;
    }

    .form-row > .form-group:has(> .postCode) {
        flex: 0 0 40%;
        max-width: 40%;
    }

    .form-row > .form-group:has(> .postName) {
        flex: 0 0 60%;
        max-width: 60%;
    }

    .form-row > .form-group:has(> #company_MobPh),
    .form-row > .form-group:has(> #company_Ph),
    .form-row > .form-group:has(> [id$="Dagligleder_FiNm"]),
    .form-row > .form-group:has(> [id$="Dagligleder_Nm"]),
    .form-row > .form-group:has(> [id$="Dagligleder_Mobil"]),
    .form-row > .form-group:has(> [id$="Dagligleder_Phone"]),
    .form-row > .form-group:has(> [id$="ProductManager_FiNm"]),
    .form-row > .form-group:has(> [id$="ProductManager_Nm"]),
    .form-row > .form-group:has(> [id$="ProductManager_Mobil"]),
    .form-row > .form-group:has(> [id$="ProductManager_Phone"]) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .kjede-checkbox {
        width: 20px;
        height: 20px;
    }

    .form-body .custom-float-right {
        float: none;
        width: 100%;
        min-height: 44px;
    }

    .form-body .form-group.row > [class*="col-"] + [class*="col-"]:has(> label:first-child) {
        margin-top: .8rem;
    }

    /* GVBApplication: each label is followed by a column holding a bare .form-check-input */
    .form-body .form-group.row:has(> div > .form-check-input) {
        display: grid;
        grid-template-columns: 28px 1fr;
        grid-auto-flow: dense;
        align-items: start;
        margin-left: 0;
        margin-right: 0;
    }

    .form-body .form-group.row:has(> div > .form-check-input) > label {
        grid-column: 2;
        max-width: none;
        padding-left: 0;
        padding-right: 0;
    }

    .form-body .form-group.row:has(> div > .form-check-input) > div {
        grid-column: 1;
        max-width: none;
        padding: 0;
    }

    .form-body .form-group.row:has(> div > .form-check-input) .form-check-input {
        position: static;
        width: 20px;
        height: 20px;
        margin: calc(.375rem + 3px) 0 0;
    }

    /* Membership/IndexV2, the group choice */
    .dummySpace {
        display: none;
    }

    .middle .form-check {
        display: flex;
        align-items: flex-start;
        gap: 10px;
    }

    .middle .form-check input[type=radio] {
        flex: none;
        margin-top: .3em;
    }

    .middle .form-check-label {
        margin-left: 0;
    }

    #_Start {
        float: none;
        width: 100%;
        margin-bottom: 12px;
    }

    .buttonsBar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        gap: 10px;
        width: auto;
        margin: 0;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid #dfe5e8;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, .08);
    }

    .buttonsBar .btn {
        flex: 1 1 0;
        float: none;
        min-height: 46px;
        font-size: 1rem;
        font-weight: 600;
    }

    /* The cookie-settings button (CookieManager.css, z-index 1050) would cover Tilbake */
    body:has(.buttonsBar) .cookie-manager-trigger,
    body:has(.buttonsBar) .cookie-manager-snackbar {
        bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    #appBox .footer {
        position: static;
        height: auto;
        padding: 12px 0;
        line-height: 1.2;
        white-space: normal;
    }

    #appBox .footer .container {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 16px;
        padding: 0 14px;
    }

    /* _Footer.cshtml sets margin-top, max-width and float inline */
    #appBox .footer .container > div {
        margin-top: 0 !important;
        max-width: none !important;
    }

    #appBox .footer .footerlogo {
        float: none !important;
        height: 24px;
        margin: 0 0 0 auto !important;
    }
}
