/**
 * WP REST API Explorer - Tab "Content" (build phase 4)
 *
 * Type navigation, lists, media gallery, previews and the single view. Colours only through
 * Bootstrap variables and the tool tokens (ui-conventions).
 */

/* Filter groups rendered into a wrapper: the wrapper takes no box of its own */
.d-contents {
    display: contents;
}

/* Type navigation: long collection names wrap; the active entry stays readable */
.wpapi-ct-nav .list-group-item {
    font-size: 0.875rem;
    padding: 0.35rem 0.5rem;
    background-color: transparent;
    color: var(--bs-body-color);
}

.wpapi-ct-nav .list-group-item.active {
    background-color: var(--tools-fill-primary, #1c73d5);
    border-color: var(--tools-fill-primary, #1c73d5);
    color: #fff;
    /* The slug under a name (Navigation: wp_navigation) was 2.69:1 on the fill */
    --bs-secondary-color: #fff;
}

.wpapi-ct-nav .list-group-item .badge {
    white-space: normal;
    text-align: start;
}

/* Filter row (like the Overview list): the fields share a row from 576 px and fill it; on
   phones each filter takes the whole width, only "Items per page" stays narrow (10…250) */
#wpapi-ct-filters > div,
#wpapi-ct-selects > div,
#wpapi-ct-rare > div,
#wpapi-ct-rare-selects > div,
#wpapi-ct-ask-form > div {
    flex: 1 1 9rem;
    min-width: 7rem;
}

#wpapi-ct-filters > .wpapi-list-filter {
    flex: 2 1 12rem;
}

#wpapi-ct-filters > div:last-child {
    flex: 0 0 auto;
    min-width: 0;
}

@media (max-width: 575.98px) {

    #wpapi-ct-filters > div:not(:last-child),
    #wpapi-ct-selects > div,
    #wpapi-ct-rare-selects > div,
    #wpapi-ct-ask-form > div {
        flex-basis: 100%;
    }

}

/* Cards of the visual list */
.wpapi-ct-card {
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 0.5rem;
}

.wpapi-ct-card .wpapi-linkbtn,
.wpapi-ct-media .wpapi-linkbtn,
.wpapi-ct-comment .wpapi-linkbtn {
    overflow-wrap: anywhere;
}

/* Media gallery: fixed thumbnail box, icon until an image is loaded on a click */
.wpapi-ct-thumb {
    height: 8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-tertiary-bg);
    font-size: 2.5rem;
    color: var(--bs-secondary-color);
    overflow: hidden;
    text-align: center;
}

.wpapi-ct-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.wpapi-ct-thumb .small {
    font-size: 0.8rem;
}

.wpapi-ct-thumb-lg {
    height: 14rem;
    margin-bottom: 0.5rem;
}

.wpapi-ct-avatar {
    flex: 0 0 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bs-tertiary-bg);
    border-radius: 50%;
    overflow: hidden;
    font-size: 1.5rem;
    color: var(--bs-secondary-color);
}

.wpapi-ct-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wpapi-ct-avatar .small {
    font-size: 0.55rem;
    line-height: 1.1;
    padding: 0.1rem;
    text-align: center;
}

.min-w-0 {
    min-width: 0;
}

/* Hierarchy and comment threads */
.wpapi-ct-tree li {
    padding-top: 0.1rem;
    padding-bottom: 0.1rem;
}

.wpapi-ct-comment {
    border-left: 2px solid var(--bs-border-color);
    padding-left: 0.5rem;
}

/* Column chooser: scrolls inside, never wider than the screen */
.wpapi-ct-cols {
    max-height: 20rem;
    overflow-y: auto;
    min-width: 14rem;
    max-width: min(28rem, 90vw);
}

/* Table view: field values may be long */
#wpapi-ct-table td {
    max-width: 24rem;
}

/* Single view: wide offcanvas on desktop, full width on phones */
.wpapi-ct-item.offcanvas-end {
    width: min(48rem, 100vw);
}

@media (max-width: 767.98px) {

    .wpapi-ct-item.offcanvas-end {
        width: 100vw;
    }

}

.wpapi-ct-preview {
    border: 1px solid var(--bs-border-color);
}

.wpapi-preview-frame {
    display: block;
    width: 100%;
    height: 60vh;
    border: 0;
    background: #fff;
    resize: vertical;
}

.wpapi-ct-links li {
    overflow-wrap: anywhere;
}

#wpapi-ct-item-jse {
    height: 60vh;
}

/* Field list of the single view: paths and values wrap inside the offcanvas on phones */
#wpapi-ct-item-body .wpapi-table th,
#wpapi-ct-item-body .wpapi-table td {
    overflow-wrap: anywhere;
}

#wpapi-ct-item-body .wpapi-table th {
    max-width: 40%;
}

/* `hidden` must win over Bootstrap's display utilities (d-flex is !important) */
#tab-content [hidden],
#wpapi-ct-item [hidden] {
    display: none !important;
}

/* UI check phase 4 (P4-5): the date filters keep their natural width — growing, "To" alone
   on the second row stretched across the whole list at 1280 px */
@media (min-width: 576px) {

    #wpapi-ct-filters > [data-wpapi-ct-dates] {
        flex: 0 1 10rem;
    }

}

/* ------------------------------------------------------------------
   UI check phase 5 answers (2026-11-02)
   ------------------------------------------------------------------ */

/* A list that needs a login and has no data: only the message and the notes (content-ui.js) */
.wpapi-ct-loginonly #wpapi-ct-filters,
.wpapi-ct-loginonly #wpapi-ct-bools,
.wpapi-ct-loginonly #wpapi-ct-viewbar,
.wpapi-ct-loginonly #wpapi-ct-summary,
.wpapi-ct-loginonly #wpapi-ct-foot {
    display: none !important;
}

#wpapi-ct-summary {
    flex: 1 1 14rem;
    min-width: 0;
}

/* The dates keep their natural width, now as a pair (before: on separate rows at 1280 px) */
@media (min-width: 576px) {

    #wpapi-ct-rare > .wpapi-ct-daterange {
        flex: 0 1 20.5rem;
    }

    #wpapi-ct-rare > .wpapi-ct-daterange > [data-wpapi-ct-dates] {
        flex: 1 1 0;
    }

}

@media (max-width: 575.98px) {

    #wpapi-ct-rare > .wpapi-ct-daterange {
        flex: 1 1 100%;
    }

    #wpapi-ct-rare > .wpapi-ct-daterange > [data-wpapi-ct-dates] {
        flex: 1 1 0;
        min-width: 0;
    }

    /* Three nested frames took 46 px on each side: only the spacing changes */
    #tab-content .card-body {
        padding-left: .5rem;
        padding-right: .5rem;
    }

    /* The switches: one small gap (a 40 px hole between the rows looked like an error) */
    #wpapi-ct-bools {
        row-gap: .25rem !important;
    }

    #wpapi-ct-bools .form-check {
        margin-bottom: 0;
    }

}

/* ------------------------------------------------------------------
   Layout, user answer 19 (2026-11-03)
   ------------------------------------------------------------------ */

/* Phones: the rare filters sit behind one control. An active one stays where it is, so it can be
   read and cleared without opening anything (classes set in content-ui.js) */
@media (max-width: 767.98px) {

    .wpapi-ct-rare-closed .wpapi-ct-rare:not(.wpapi-ct-rare-on),
    .wpapi-ct-rare-closed #wpapi-ct-bools:not(:has(.wpapi-ct-rare-on)) {
        display: none !important;
    }

    /* Shares its row with "Items per page" while closed; alone on a row as soon as a field follows it */
    #wpapi-ct-filters > div.wpapi-ct-raretoggle {
        flex: 1 1 0;
        min-width: 9rem;
    }

}

/* Locked "Load all" buttons: no requests left, or a pull is running. Clicking one says why */
#wpapi-ct-pull[aria-disabled="true"],
#wpapi-ct-all[aria-disabled="true"] {
    opacity: .65;
    cursor: not-allowed;
}

/* The technical line of a list (route, requests): stays small and quiet */
.wpapi-ct-tech {
    font-size: .75rem;
}

/* The parameter of the site behind the plain label in "Ask the site" */
.wpapi-ct-askparam {
    font-size: .75rem;
}

/* A list that needs a login has no check boxes either */
.wpapi-ct-loginonly #wpapi-ct-selrow {
    display: none !important;
}

/* Desktop: the type navigation stays in view while the list scrolls. It stops below the sticky
   run strip and above the fixed bottom bar (their heights come from content-ui.js) and scrolls
   by itself only when it is taller than that. The side padding keeps focus rings from being cut
   by the overflow; the negative margin keeps the column where it was. */
@media (min-width: 992px) {

    .wpapi-ct-side {
        position: sticky;
        top: calc(var(--wpapi-ct-side-top, 0px) + .5rem);
        max-height: max(14rem, calc(100vh - var(--wpapi-ct-side-top, 0px) - var(--wpapi-ct-side-bottom, 0px) - 1rem));
        margin-inline: -.25rem;
        padding-inline: .25rem;
        padding-bottom: .25rem;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .wpapi-ct-nav .list-group-item:focus-visible {
        outline-offset: -2px;
    }

    /* "Load all readable" stays at the top of the sidebar (visual check 2026-11-04): the button
       sticks, its cost line scrolls away with the list. Focus stops below the button */
    /* Image review 2026-11-06: the cost line scrolled half under the pinned button ("No requests
       left …" cut in two); button and line now stick together. scroll-padding-top follows the
       height of the block (content-ui.js syncSideMore) */
    .wpapi-ct-all-wrap {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--bs-body-bg);
        box-shadow: 0 .25rem 0 var(--bs-body-bg);
    }

    .wpapi-ct-all-wrap > p:last-child {
        margin-bottom: 0 !important;
        padding-bottom: .25rem;
    }

    .wpapi-ct-side:has(.wpapi-ct-all-wrap:not([hidden])) {
        scroll-padding-top: 2.5rem;
    }

    /* Shows that the list goes on below the edge: a line of its own with a small arrow, only while
       there is more (content-ui.js). Image review round 5: as a transparent overlay it was laid over
       the last entry ("Authors … , below"); now it is opaque and has its own room in the flow.
       Takes no clicks. */
    .wpapi-ct-side-more {
        position: sticky;
        bottom: 0;
        z-index: 1;
        height: 1.5rem;
        text-align: center;
        line-height: 1.5rem;
        font-size: .75rem;
        color: var(--bs-secondary-color);
        background: var(--bs-body-bg);
        pointer-events: none;
    }

}
