/* Phone and tablet fixes for the student area. Loaded last by AppAsset and LandingAsset. */

#main_image_back_top, #main_image_back_right {
    max-width: 100%;
    pointer-events: none;
}

/* GridView's plain LinkPager (<li><a>) had no padding: 5px wide page numbers */
.pagination > li > a, .pagination > li > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: var(--ua-radius-sm, 8px);
    color: var(--ua-color-text, #fff);
    text-decoration: none;
}
.pagination > li.active > a, .pagination > li.active > span {
    background-color: var(--ua-color-brand, #959c6d);
}
.pagination > li.disabled > span {
    opacity: .5;
}
.pagination {
    flex-wrap: wrap;
    gap: 4px;
}

/* flex child of <main>: without this a wide table or calendar widens the whole page */
.content_main {
    min-width: 0;
}

/* courses.css keeps 150px side margins, too much below a wide desktop */
@media screen and (max-width: 1200px) {
    .content_main {
        margin-left: 24px;
        margin-right: 24px;
    }
}
@media screen and (max-width: 800px) {
    .content_main {
        margin-left: 0;
        margin-right: 0;
    }
}


/* tablets: the expanded header has no room for the text logo next to the menu */
@media screen and (min-width: 768px) and (max-width: 1100px) {
    header #logo_head {
        display: none;
    }
}

@media screen and (max-width: 800px) {
    html, body {
        overflow-x: clip;
    }

    /* iOS zooms into form fields with text under 16px */
    input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
        font-size: 16px !important;
    }

    /* header: one row, logos shrink, a menu button that looks like the rest of the site */
    #logo_head_tsuul {
        height: 48px;
        margin-right: 8px;
    }
    header .navbar .container {
        width: 100%;
        padding: 0 12px;
        flex-wrap: nowrap;
    }
    header .navbar .container:has(.navbar-collapse.show) {
        flex-wrap: wrap;
    }
    header .navbar .container .navbar-collapse.show {
        flex-basis: 100%;
    }
    .navbar-brand {
        display: flex;
        align-items: center;
        min-width: 0;
        width: auto;
        flex: 1 1 auto;
        margin-right: 8px;
        overflow: hidden;
    }
    header #logo_head {
        width: auto;
        max-width: calc(100% - 56px);
        max-height: 40px;
    }
    .navbar .navbar-toggler,
    header.not_fixed .navbar .container .navbar-toggler {
        width: 48px;
        height: 44px;
        flex: 0 0 auto;
        padding: 0;
        border: 1px solid var(--ua-color-brand, #959c6d);
        border-radius: 10px;
        background-color: var(--ua-color-surface, #292929) !important;
    }
    .navbar .navbar-toggler:focus {
        box-shadow: 0 0 0 3px rgba(149, 156, 109, .5);
    }
    .navbar .navbar-toggler .navbar-toggler-icon {
        display: inline-block;
        width: 26px;
        height: 26px;
        vertical-align: middle;
        background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23fff' stroke-linecap='round' stroke-width='2.4' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") center / 100% no-repeat !important;
    }
    header .container .navbar-collapse.show,
    header .container .navbar-collapse.collapsing {
        align-items: stretch !important;
        gap: 8px;
        margin-top: 8px;
        padding: 16px;
        border: 1px solid #3a3a3a;
        border-radius: 12px;
        background-color: var(--ua-color-bg, #1c1c1c) !important;
        box-shadow: 0 12px 32px rgba(0, 0, 0, .6);
    }
    header .container .navbar-collapse.show > * {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
    header .navbar-collapse.show .notification-link,
    header .navbar-collapse.show .profile-link,
    header .navbar-collapse.show .logout,
    header .navbar-collapse.show .login-button,
    header .navbar-collapse.show select#lang-switcher {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 44px;
    }
    header .navbar-collapse.show .logout,
    header .navbar-collapse.show .login-button {
        border: 1px solid var(--ua-color-brand, #959c6d);
        border-radius: 10px;
    }

    main {
        padding-top: 96px;
    }
    #main_page_title {
        font-size: 24px;
        overflow-wrap: anywhere;
    }

    /* calendar toolbar */
    .fc .fc-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .fc .fc-button {
        min-height: 40px;
        min-width: 40px;
    }
    .fc .fc-toolbar-title {
        font-size: 1.2em;
    }

    /* tables in the student area scroll inside their card, not the page */
    .grid-view, .table-responsive-auto {
        max-width: 100%;
        overflow-x: auto;
    }
}

/* lesson text and exercises: pictures never wider than the card */
.accordion-body-content img, .lesson-exercise img, .exam-tab-content img {
    max-width: 100%;
    height: auto;
}

/* exercises on phones ("html body" wins over the widget stylesheets loaded with the exercise) */
@media screen and (max-width: 800px) {
    html body .lesson-exercise input[type=text], html body .lesson-exercise select,
    html body .exam-tab-content input[type=text], html body .exam-tab-content select {
        min-height: 40px;
    }
    html body .add-answer {
        min-height: 44px;
        padding: 8px 16px;
    }
    html body .lesson-exercise a, html body .exam-tab-content a {
        max-width: 100%;
    }

    /* upload a recording / PDF: label above the button instead of both on one clipped row */
    html body .csbgw-answers, html body .igp-answers, html body .sagt-answers, html body .we-answers {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 12px;
    }
    html body .custom-file-label {
        flex: 1 1 100%;
        margin: 0;
        font-size: 16px;
        text-align: center;
        overflow-wrap: anywhere;
    }
    html body .custom-file-btn {
        margin: 0;
        min-height: 44px;
        padding: 8px 16px;
        font-size: 16px;
    }
    html body .csbgw-question-wrapper, html body .sagt-question-wrapper, html body .we-question-wrapper,
    html body .igp-question-wrapper {
        margin: 10px 0;
        font-size: 18px;
    }
    /* the given words of "create a story" wrap instead of running off both edges */
    html body .csbgw-question {
        flex-wrap: wrap;
        gap: 4px 6px;
        padding: 12px;
        font-size: 20px;
    }
}

/* login card (login_view.css) was a fixed 600px box with 100px margins */
@media screen and (max-width: 800px) {
    html body .site-login {
        width: 100%;
        max-width: 600px;
        margin: 90px 0 40px;
        padding: 24px 20px;
    }
    #forgot-password, #invite-registration a {
        display: inline-block;
        padding: 10px 0;
    }
    /* landing footer */
    footer {
        height: auto !important;
    }
    .footer-menu .row div {
        margin-bottom: 0;
    }
    .footer-menu .row div a {
        display: inline-flex;
        align-items: center;
        min-height: 40px;
    }
    .footer-social-links .social-icons a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }
}
