/*
 * Moodulkapp – mobile view (phones and small tablets)
 * Loaded after main.css. Desktop (wider than 760px) is not affected at all.
 * The door and module drawings keep their exact proportions: js/mobile.js scales them to the screen width.
 */

/* ---------- touch screens: what desktop shows on mouse hover is always visible ---------- */
@media (hover: none) {
    .door .button-holder {
        opacity: 1;
        visibility: visible;
        filter: none;
    }
    .modules .module-items .module-item .button-holder,
    .modules .module-items .module-item-niche .button-holder {
        display: block;
    }
}

@media (max-width: 760px) {
    body {
        font-size: 14px;
        -webkit-text-size-adjust: 100%;
    }

    .page-wrap {
        padding: 0;
    }

    /* header: menu on the first row, help + logo on the right */
    .header {
        height: auto;
        min-height: 52px;
        margin-bottom: 0;
        padding: 8px 76px 8px 12px;
        box-sizing: border-box;
    }
    .header .header-left,
    .header .header-left .main-nav,
    .header .header-left ul {
        width: auto;
        height: auto;
    }
    .header .header-left ul {
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 6px 16px;
    }
    .header .header-left ul li {
        display: block;
        margin: 0;
        padding: 0;
        float: none;
    }
    .header .main-menu-item {
        display: inline-block;
        padding: 6px 0;
        font-size: 12px;
    }
    .header .header-right {
        top: 0;
        right: 0;
        height: 100%;
        display: flex;
        align-items: center;
    }
    .header .help-button {
        margin: 0 8px 0 0;
        font-size: 0;          /* icon only */
        width: 20px;
        padding-right: 0;
        background-position: 100% 0;
    }
    .header .logo-holder img {
        width: 60px;
        height: auto;
    }

    /* hover does not exist on a phone: door and module buttons are always shown */
    .door .button-holder {
        opacity: 1;
        visibility: visible;
        filter: none;
    }
    .modules .module-items .module-item .button-holder,
    .modules .module-items .module-item-niche .button-holder {
        display: block;
    }

    .content-holder {
        min-width: 0;
        min-height: calc(100vh - 52px);
        overflow: clip;        /* keeps the sticky footer working */
    }
    .content .wrap {
        padding-left: 12px;
        padding-right: 12px;
        box-sizing: border-box;
    }
    .content h1 {
        font-size: 18px;
        padding: 18px 0 10px;
    }
    .content h2 {
        font-size: 14px;
        line-height: 140%;
        padding-bottom: 12px;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    /* ---------- home ---------- */
    .home {
        position: static;
        margin-top: 0;
        padding: 24px 0 32px;
    }
    .home .choice {
        padding-top: 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 28px;
    }
    .home .step-choice.sliding-doors {
        margin-right: 0;
    }
    .home .step-choice .image-holder {
        padding-bottom: 10px;
    }

    /* ---------- doors ---------- */
    .doors .door-count {
        padding-top: 20px;
    }
    .doors .count-items {
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }
    .doors .count-items .count-item {
        width: auto;
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
    }
    .doors .count-items .count-item .image-holder {
        width: auto;
        height: auto;
    }
    .doors .count-items .count-item .image-holder img {
        width: 100%;
        height: auto;
    }
    .doors .count-items .count-item .button-holder .mk-button {
        padding-left: 10px;
        padding-right: 10px;
    }
    .doors .door-types {
        padding-top: 16px;
        padding-bottom: 8px;
    }

    .doors .current-doors .current-doors-settings,
    .modules .current-modules .current-modules-settings {
        display: block;
        width: auto;
        margin: 0;
    }
    .doors .current-doors .current-doors-settings .settings-inner,
    .modules .current-modules .current-modules-settings .settings-inner {
        width: auto;
        padding: 16px 0 8px;
        border-right: none;
        border-bottom: 1px solid #EEEEEE;
    }
    .doors .current-doors .current-doors-settings .settings-inner .opening-settings input {
        width: 90px;
        font-size: 16px;      /* no zoom-in on iPhone when typing */
    }
    .doors .current-doors .current-doors-settings .settings-inner select,
    .order-form select {
        width: 100%;
        font-size: 16px;
        min-height: 36px;
    }
    .doors .current-doors .current-doors-settings .settings-inner .profile .profile-cross {
        display: none;        /* profile cross-section drawing takes a full screen on a phone */
    }

    .doors .current-doors .current-doors-preview,
    .modules .current-modules-preview {
        display: block;
        width: auto;
        height: auto;
        padding-top: 16px;
        padding-bottom: 16px;
        overflow: hidden;
    }
    /* ---------- modules ---------- */
    .modules .module-items {
        padding-top: 12px;
    }
    .modules .module-items .module-group {
        margin: 0 6px 18px;
    }
    .modules .module-items .module-item .button-holder,
    .modules .module-items .module-item-niche .button-holder {
        position: static;
        margin-top: 4px;
    }
    .modules .module-items .module-item .button-holder .mk-button {
        padding: 6px 6px 4px;
        min-width: 0;
        font-size: 11px;
    }
    .modules .current-modules-preview .add-more-modules {
        width: auto;
    }

    /* module description popup becomes a sheet at the bottom of the screen */
    .module-preview-holder .module-preview {
        position: fixed !important;
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        bottom: 84px !important;
        width: auto !important;
        height: auto !important;
        max-height: 50vh;
        overflow: auto;
        box-sizing: border-box;
        padding: 12px;
    }
    .module-preview-holder .module-preview .left,
    .module-preview-holder .module-preview .right {
        width: 48%;
    }
    .module-preview-holder .module-preview .left img {
        max-height: 30vh;
        width: auto;
    }

    /* ---------- material / type dialog ---------- */
    #modal .modal-content {
        top: 8px !important;
        left: 8px !important;
        right: 8px;
        bottom: 8px;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    #modal .modal-content .modal-header {
        position: sticky;
        top: 0;
        z-index: 2;
    }
    .modal-content .types-items {
        min-width: 0;
        padding: 16px 8px;
    }
    .modal-content .types-items .door-item {
        margin: 0 6px 16px;
    }
    .modal-content .change-door-material-holder {
        width: auto;
    }
    .modal-content .change-door-material-holder .change-material-header .l {
        width: auto;
    }
    .modal-content .change-door-material-holder .fields,
    .modal-content .change-door-material-holder .select {
        width: auto;
        height: auto;
        max-width: 48%;
    }

    /* ---------- help panel ---------- */
    .help-holder {
        width: 100%;
        box-sizing: border-box;
        padding: 44px 16px 16px;
        position: fixed;
        z-index: 6000;
    }
    .help-holder .help-shadow {
        display: none;
    }
    .help-holder .help-items p {
        padding-right: 0;
    }

    /* ---------- bottom action bar: always in reach ---------- */
    .main-footer-push {
        display: none;
    }
    .main-footer {
        position: sticky;
        bottom: 0;
        z-index: 50;
        box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.15);
    }
    .main-footer .footer-buttons {
        height: auto;
        padding: 8px;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .main-footer .footer-buttons .left,
    .main-footer .footer-buttons .right {
        float: none;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }
    .main-footer .footer-buttons .mk-button,
    .main-footer .footer-buttons .left .mk-button,
    .main-footer .footer-buttons .right .mk-button {
        margin: 0;
        flex: 1 1 auto;
        min-width: 0;
        height: auto;
        padding: 11px 10px 9px;
        text-align: center;
        box-sizing: border-box;
    }

    /* ---------- order form ---------- */
    .content.order .errors,
    .order-items .order-items-hidden-content,
    .order-items .hide-holder,
    .order-items .order-items-visible-content,
    .total-order,
    .user-info-holder {
        width: auto;
    }
    .order-items .order-items-visible-content {
        overflow-x: auto;
    }
    .order-form {
        width: auto;
        padding: 12px 0 24px;
    }
    .order-form form > div {
        display: block;
        margin-right: 0;
    }
    .order-form input[type=text],
    .order-form input[type=text].form-phone,
    .order-form textarea,
    .order-form .form-comments {
        width: 100%;
        box-sizing: border-box;
        font-size: 16px;
    }
    .order-form form .fitting-selector {
        width: auto;
    }
    .user-info-holder .user-info {
        width: auto;
    }
    .user-info-holder .user-info dt {
        float: none;
        width: auto;
        text-align: left;
        white-space: normal;
        font-weight: 700;
    }
}
