/**
 * WP REST API Explorer - Tab "Search" (plan 04 §5)
 *
 * @package   JPKCom_Tools
 * @subpackage WP_API
 */

/* One hit per row, separated by a line */
.wpapi-se-hit {
    border-bottom: 1px solid var(--bs-border-color);
    padding: .5rem 0;
}

.wpapi-se-hit:last-child {
    border-bottom: 0;
}

/* The search term gets a row of its own below lg, then shares it; "In field" grows with the row */
.wpapi-se-qwrap {
    flex: 1 1 100%;
}

.wpapi-se-fwrap {
    flex: 1 1 12rem;
}

@media (min-width: 992px) {

    .wpapi-se-qwrap {
        flex: 2 1 20rem;
    }

}

/* Bootstrap's d-flex wins over the hidden attribute; hidden must win in this tab */
#tab-search [hidden] {
    display: none !important;
}

/* UI check phase 4 (P4-5): hit marks without Bootstrap's mark padding — inside a word the
   padding looked like a space ("the n" for "then") */
#wpapi-se-hits mark {
    padding: 0;
    border-radius: 2px;
}

/* ------------------------------------------------------------------
   UI check phase 5 gaps (2026-10-29)
   ------------------------------------------------------------------ */

/* Field lines of a hit: a little space between them (they ran together on phones) */
.wpapi-se-fields > li {
    margin-bottom: .25rem;
}

@media (max-width: 575.98px) {

    /* Field name on a line of its own above the value; the title of a hit always under its badge
       (short and long titles gave two layouts) */
    .wpapi-se-fields .wpapi-se-fname {
        display: block;
    }

    .wpapi-se-hit .wpapi-se-title {
        flex: 1 1 100%;
    }

    /* Options: one per line with the same small gap (two, then one, then one with a 40 px hole) */
    .wpapi-se-opts {
        flex-direction: column;
        gap: .25rem !important;
    }

}

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

/* A locked button must look locked (search-ui.js says why on a click) */
#wpapi-se-filter[aria-disabled="true"] {
    opacity: .65;
    cursor: not-allowed;
}

/* The row of buttons and pager is empty without hits */
#wpapi-se-toprow:not(:has(> :not([hidden]))) {
    display: none !important;
}

/* Section headings of the list: stronger than the hit titles below them */
.wpapi-se-group h4 {
    font-weight: 600;
    margin-top: .5rem;
}

/* "HTML as text" is a note, not a third button */
.wpapi-se-htmlbadge {
    font-weight: 400;
    color: var(--bs-secondary-color) !important;
}

.wpapi-se-fields {
    margin-bottom: .5rem !important;
}

@media (max-width: 575.98px) {

    /* Route hits: under "Routes (N hits)" the badge says the same and the pink path nearly repeats
       the title ("Copy path" stays): one route took five lines [Claude] */
    .wpapi-se-hit-route > div:first-child > .badge,
    .wpapi-se-hit-route > .wpapi-se-path {
        display: none;
    }

    /* "Type" full width like "Search for" and "In field" */
    #tab-search div:has(> #wpapi-se-group) {
        flex: 1 1 100%;
    }

    #tab-search div:has(> #wpapi-se-group) select {
        width: 100%;
    }

}

/* A hit loaded by click: its path carries an internal label and the route stands in the badge
   already. The element stays, it is the address of the hit in the store (visual check 2026-11-04) */
.wpapi-se-hit-click > .wpapi-se-path {
    display: none;
}

/* Open on a hit loaded by click: the kept JSON in place, as text */
.wpapi-se-clickview pre {
    max-height: 24rem;
    overflow: auto;
    white-space: pre-wrap;
}
