/* Mobile corrections for the original Startup portal.
 * Keep original assets, typography and component breakpoints unchanged.
 * Admin PHP tables use adm-table-wrap; source CSS only defines adm-table-scroll.
 */
@media (max-width: 768px) {
    /* Preserve the public navigation while giving its controls phone-sized targets. */
    .public-app > .site-header .brand,
    .public-app > .site-header .header-actions > a {
        min-height: 44px;
    }

    .public-app > .site-header .header-actions > a {
        min-width: 44px;
        align-items: center;
        justify-content: center;
    }

    .public-app > .site-header .header-actions > a:not(.pale) {
        display: inline-flex;
    }

    .public-app > .site-header .menu-toggle {
        display: inline-grid;
        place-items: center;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }

    .public-app > .site-header .public-nav.open a {
        min-width: 44px;
        min-height: 44px;
    }

    .public-app .p-filter-search {
        height: auto;
        min-height: 46px;
        align-items: stretch;
    }

    .public-app .p-filter-search input {
        min-height: 44px;
    }

    .public-app .p-filter-search button,
    .public-app .p-view-switch button {
        min-width: 44px;
        min-height: 44px;
    }

    .public-app .p-list-top {
        flex-wrap: wrap;
        gap: 12px;
    }

    .public-app .p-program-card .p-card-actions .p-btn,
    .public-app .lp-program-card .lp-action {
        min-width: 44px;
        min-height: 44px;
        white-space: normal;
    }

    /* Fixed source heights must grow when the touch targets and titles need room. */
    .public-app .p-program-card,
    .public-app .p-programs-grid.list .p-program-card {
        height: auto;
        min-height: 200px;
    }

    .public-app .p-program-title,
    .public-app .lp-program-title {
        word-break: keep-all;
        overflow-wrap: anywhere;
    }

    .workspace .sidebar-toggle,
    .workspace > .site-header .menu-toggle {
        min-width: 44px;
        min-height: 44px;
    }

    .workspace > .site-header .menu-toggle {
        display: inline-grid;
        place-items: center;
        padding: 0;
    }

    .workspace > .site-header .header-actions > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
    }

    .workspace .learning-hub .lh-tabs > a,
    .workspace .learning-hub .lh-filter input:not([type="hidden"]),
    .workspace .learning-hub .lh-filter select,
    .workspace .learning-hub .lh-filter button,
    .workspace .learning-hub .lh-activity > .up-outline,
    .workspace .learning-hub .lh-actions > a,
    .workspace .learning-hub .lh-course-footer > a,
    .workspace .learning-hub .lh-section-title > .lh-text-link,
    .workspace .learning-hub .lh-heading > .up-outline,
    .workspace .learning-hub .lh-calendar-month > a,
    .workspace .learning-hub .lh-calendar-views > a,
    .workspace .learning-hub .lh-calendar-meta > .lh-text-link {
        min-height: 44px;
    }

    .workspace .learning-hub .lh-calendar-month > a,
    .workspace .learning-hub .lh-calendar-views > a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
    }

    .workspace .learning-hub .lh-calendar-month {
        flex-wrap: wrap;
    }

    /* Native admin dialogs retain the source modal backdrop and heading. */
    body.startup-portal-theme dialog.adm-modal::backdrop {
        background: #0b193c66;
        backdrop-filter: blur(3px);
    }

    body.startup-portal-theme dialog.adm-modal > h2:first-child {
        font-size: 18px;
        letter-spacing: -.4px;
    }

    /* Native navigation anchors use the original detail-tab button tokens. */
    /* The tablet workspace leaves less room than the source filter row needs. */
    .workspace .adm-filters {
        flex-wrap: wrap;
    }

    .workspace .adm-tabs {
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
    }

    .workspace .adm-detail-tabs > a {
        position: relative;
        background: transparent;
        border: 0;
        padding: 11px 3px;
        font-size: 12px;
        font-weight: 600;
        color: #8591a8;
        white-space: nowrap;
    }

    .workspace .adm-detail-tabs > a.active {
        color: #0759f7;
    }

    .workspace .adm-detail-tabs > a.active::after {
        position: absolute;
        bottom: -1px;
        left: 0;
        right: 0;
        height: 2px;
        content: '';
        background: #0759f7;
    }

    /* Keep Moodle's privacy link readable beside the original portal footer. */
    body.startup-portal-theme > .tool_dataprivacy {
        padding: 12px 17px;
        border-top: 1px solid #e6edf7;
        background: #fcfdff;
        color: #34568a;
        font-size: 12px;
        line-height: 1.6;
    }

    body.startup-portal-theme > .tool_dataprivacy a {
        text-decoration: underline;
        text-underline-offset: 2px;
    }

    /* The single-column community grid must shrink around ellipsized summaries. */
    .p-community-layout > section {
        min-width: 0;
    }

    /* Keep full activity menu labels in their own horizontal scroll area. */
    .campus-tabs {
        overflow-x: auto;
        overscroll-behavior-x: contain;
    }

    /* Source underline extends one pixel below the tab row; only horizontal scroll is useful. */
    .workspace .op-tabs {
        overflow-y: hidden;
    }

    /* PHP company tabs are anchors; restore the source button tab styling. */
    .workspace .op-tabs > a {
        flex: 1;
        padding: 13px 16px;
        border: 0;
        border-bottom: 3px solid transparent;
        background: transparent;
        color: #5e7399;
        font-size: 14px;
        font-weight: 650;
        line-height: 1.5;
        margin-bottom: -1px;
        min-width: max-content;
        text-align: center;
    }

    .workspace .op-tabs > a:hover {
        background: #f7faff;
        color: #0755ff;
    }

    .pd-root .pd-tabs { min-height: 45px; }

    .pd-root .pd-tabs > button,
    .pd-root .pd-apply-button,
    .pd-root .pd-bookmark-button,
    .pd-root .pd-faq-list summary,
    .pd-root .pd-link-button { min-height: 44px; }

    .workspace .op-tabs > a.active {
        color: #0755ff;
        border-bottom-color: #0755ff;
    }

    .workspace .adm-table-wrap {
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 340px) {
    .public-app > .site-header,
    .workspace > .site-header {
        gap: 4px;
        padding-left: 12px;
        padding-right: 12px;
    }

    .public-app > .site-header .header-actions,
    .workspace > .site-header .header-actions {
        gap: 4px;
    }
}

@media (max-width: 760px) {
    body.startup-portal-theme dialog.adm-modal > h2:first-child {
        font-size: 17px;
    }

    .workspace .op-tabs > a {
        padding: 10px 15px;
        font-size: 13px;
    }
}

@media (max-width: 730px) {
    /* Preserve access to the privacy link above the fixed member navigation. */
    body.startup-portal-theme:has(.mobile-work-nav) > .tool_dataprivacy {
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

}
