/*
 * TPM profile chrome — loaded with js/tpm-profile-chrome.js (see functions.php).
 *
 * Part 1. Project Workflow header row = breadcrumb + tabs, ALWAYS on one line, at every width.
 *   The breadcrumb is "My Project › project" only (the active tab is already shown by the tabs).
 *   When the row gets narrow, the breadcrumb gives way like the TPM Tool one:
 *   project title shrinks with "…" first, then "My Project" turns into an icon, then folds
 *   into the "…" menu; then the tabs keep only their icons; last, the project turns into an icon.
 *   The JS adds/removes the state classes.
 * Part 2. Mobile and tablet (≤1024px), profile pages: the site header and the profile
 *   menu slide away so the workspace starts with the breadcrumb; a pull-down at the top
 *   (or the handle) brings them back, like iOS / Android apps. The footer stays.
 */

/* ---------- Part 1: breadcrumb + tabs row ---------- */

/* one row at every width (the theme turns it into a column at ≤990px) */
.learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top,
.learn-press-tabs_workflow .learn-press-tabs_top {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}
.learn-press-tabs_workflow .learn-press-tabs_top > .tpm-breadcrumb {
    flex: 1 1 auto;
    min-width: 0;
    align-self: center;
}
.learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top > .learn-press-nav-tabs {
    display: flex !important;
    flex: 0 0 auto;
    flex-wrap: nowrap !important;
    width: auto !important;
    min-width: 0;
    margin: 0 !important;
}
.learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top > .learn-press-nav-tabs li {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* the active tab is not repeated in the breadcrumb */
.learn-press-tabs_workflow .tpm-breadcrumb .tpm-breadcrumb-tab-group {
    display: none !important;
}

/* tabs with icons only (set by the JS when the row is short; on phones the theme does it) */
.learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top.tpm-tabs-icon-only > .learn-press-nav-tabs li a {
    display: flex !important;
    align-items: center;
    font-size: 0 !important;
    padding: 8px 14px !important;
}
.learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top.tpm-tabs-icon-only > .learn-press-nav-tabs li a i {
    font-size: 14px !important;
    margin: 0 !important;
}
@media (max-width: 767px) {
    .learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top > .learn-press-nav-tabs li a {
        padding: 3px 12px !important;
    }
    .learnpress-profile .learn-press-tabs_workflow .learn-press-tabs_top > .learn-press-nav-tabs li a i {
        margin: 0 !important;
    }
}

.tpm-breadcrumb .tpm-breadcrumb-content {
    flex-wrap: nowrap;
    min-width: 0;
    overflow: hidden;
}
.tpm-breadcrumb .tpm-bc-item,
.tpm-breadcrumb .tpm-breadcrumb-separator,
.tpm-breadcrumb .tpm-bc-more {
    flex: 0 0 auto;
}
/* the project crumb is the one that gives way; the JS treats it as "does not fit"
   once its title would go below 5em */
.tpm-breadcrumb .tpm-breadcrumb-current.tpm-bc-item[data-tpm-bc="project"] {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}
.tpm-breadcrumb span.tpm-bc-label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* the title keeps a readable minimum before the labels start turning into icons */
.tpm-breadcrumb .tpm-breadcrumb-current span.tpm-breadcrumb-project-title {
    flex: 0 1 auto;
    min-width: 5em;
}
.tpm-breadcrumb .tpm-bc-icon {
    flex-shrink: 0;
}
.tpm-breadcrumb .tpm-project-type-icon {
    flex-shrink: 0;
}

/* states set by the JS */
.tpm-breadcrumb .tpm-bc-item.is-icon-only .tpm-bc-label {
    display: none !important;
}
.tpm-breadcrumb .tpm-breadcrumb-current.is-icon-only span.tpm-breadcrumb-project-title {
    min-width: 0;
}
.tpm-breadcrumb .tpm-breadcrumb-current.is-icon-only {
    cursor: pointer;
}
.tpm-breadcrumb .is-folded,
.tpm-breadcrumb .tpm-bc-more[hidden] {
    display: none !important;
}

/* "…" button */
.tpm-breadcrumb .tpm-bc-more {
    display: flex;
    align-items: center;
}
.tpm-breadcrumb .tpm-bc-more-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 26px;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 4px;
    background: transparent !important;
    box-shadow: none !important;
    color: #bac8d3 !important;
    line-height: 1;
    cursor: pointer;
}
.tpm-breadcrumb .tpm-bc-more-btn:hover,
.tpm-breadcrumb .tpm-bc-more-btn[aria-expanded="true"] {
    color: #b85450 !important;
    background: rgba(255, 255, 255, .12) !important;
}
.tpm-breadcrumb .tpm-bc-more-btn:focus-visible,
.tpm-breadcrumb .tpm-bc-item:focus-visible {
    outline: 2px solid #b85450;
    outline-offset: 2px;
}

/* menu and tooltip live in <body> (the breadcrumb row clips overflow) */
.tpm-bc-menu {
    position: fixed;
    z-index: 100001;
    min-width: 200px;
    max-width: calc(100vw - 16px);
    padding: 4px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(16, 32, 48, .22);
}
.tpm-bc-menu[hidden] {
    display: none !important;
}
.tpm-bc-menu a,
.tpm-bc-menu span.tpm-bc-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 4px;
    color: #2c3e50;
    font-family: "Roboto Condensed", sans-serif;
    font-size: 15px;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tpm-bc-menu a:hover,
.tpm-bc-menu a:focus-visible {
    background: #eef2f6;
    color: #b85450;
    outline: none;
}
.tpm-bc-menu img {
    width: 18px;
    flex-shrink: 0;
}

.tpm-bc-tooltip {
    position: fixed;
    z-index: 100002;
    max-width: min(320px, calc(100vw - 16px));
    padding: 4px 8px;
    border-radius: 4px;
    background: #1f2d3a;
    color: #fff;
    font-family: "Roboto Condensed", sans-serif;
    font-size: 13px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}
.tpm-bc-tooltip.is-visible {
    opacity: 1;
}

/* ---------- Part 2: mobile / tablet chrome ---------- */

.tpm-chrome-handle {
    display: none;
}

@media (max-width: 1024px) {

    body.tpm-chrome-on header#masthead,
    body.tpm-chrome-on #profile-sidebar,
    body.tpm-chrome-on .lp-user-cover-image_background,
    body.tpm-chrome-on .wrapper-profile-header {
        overflow: hidden;
        max-height: var(--tpm-chrome-h, 1000px);
        transition:
            max-height 320ms cubic-bezier(.2, .8, .2, 1),
            transform 320ms cubic-bezier(.2, .8, .2, 1),
            opacity 200ms ease,
            padding 320ms cubic-bezier(.2, .8, .2, 1),
            margin 320ms cubic-bezier(.2, .8, .2, 1);
    }

    body.tpm-chrome-on.tpm-chrome-hidden header#masthead,
    body.tpm-chrome-on.tpm-chrome-hidden #profile-sidebar,
    body.tpm-chrome-on.tpm-chrome-hidden .lp-user-cover-image_background,
    body.tpm-chrome-on.tpm-chrome-hidden .wrapper-profile-header {
        max-height: 0 !important;
        min-height: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        border: 0 !important;
        opacity: 0;
        transform: translateY(-100%);
        pointer-events: none;
    }

    /* the gap the theme keeps for the fixed header */
    body.tpm-chrome-on .container.site-content {
        transition: padding-top 320ms cubic-bezier(.2, .8, .2, 1);
    }
    body.tpm-chrome-on.tpm-chrome-hidden .container.site-content,
    body.tpm-chrome-on.tpm-chrome-hidden #main-content > .learnpress {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* the footer stays: people go to other pages from it */

    /* breadcrumb reads well at the very top */
    body.tpm-chrome-on .tpm-breadcrumb {
        padding: 6px 8px;
    }

    /* small grabber at the top: tap or pull to bring the menu back */
    body.tpm-chrome-on .tpm-chrome-handle {
        display: flex;
        position: fixed;
        top: 0;
        left: 50%;
        z-index: 100000;
        width: 64px;
        height: 18px;
        margin: 0 0 0 -32px !important;
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        align-items: flex-start;
        justify-content: center;
        cursor: pointer;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-100%);
        transition: opacity 200ms ease, transform 200ms ease;
    }
    body.tpm-chrome-on .tpm-chrome-handle::before {
        content: "";
        display: block;
        width: 40px;
        height: 5px;
        margin-top: 5px;
        border-radius: 3px;
        background: rgba(44, 62, 80, .45);
    }
    body.tpm-chrome-on.tpm-chrome-hidden .tpm-chrome-handle {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.tpm-chrome-on header#masthead,
    body.tpm-chrome-on #profile-sidebar,
    body.tpm-chrome-on .lp-user-cover-image_background,
    body.tpm-chrome-on .wrapper-profile-header,
    body.tpm-chrome-on .container.site-content,
    body.tpm-chrome-on .tpm-chrome-handle {
        transition: none !important;
    }
}
