/**
 * WP REST API Explorer - Security tab
 *
 * @package   JPKCom_Tools
 * @subpackage WP_API
 * @version   0.5.0
 */

/* Bootstrap's display utilities win over [hidden] (same trap as content.css / search.css) */
#tab-security [hidden] {
    display: none !important;
}

.wpapi-sec-qwrap {
    flex: 1 1 14rem;
    min-width: 0;
}

.wpapi-sec-list {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.wpapi-sec-item {
    border-top: 1px solid var(--bs-border-color);
}

.wpapi-sec-item:first-child {
    border-top: none;
}

.wpapi-sec-item > summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    overflow-wrap: break-word;
}

.wpapi-sec-item > summary .badge {
    vertical-align: 0.1em;
}

.wpapi-sec-detail {
    padding: 0 0.75rem 0.75rem 1.75rem;
    overflow-wrap: break-word;
}

/* Site values (paths, URLs, masked values) wrap instead of widening the page */
.wpapi-sec-detail code,
#wpapi-sec-table code,
#wpapi-sec-probes code,
#wpapi-sec-scan code,
.wpapi-sec-raw-item code {
    overflow-wrap: anywhere;
}

.wpapi-sec-excerpt,
.wpapi-sec-rawbody {
    max-height: 16rem;
    overflow: auto;
    padding-right: 0.75rem;
}

.wpapi-sec-revealed {
    color: var(--bs-warning-text-emphasis);
}

.wpapi-sec-goto {
    overflow-wrap: anywhere;
}

/* JSON tree box: fixed height, the editor scrolls inside */
.wpapi-sec-jse {
    height: 60vh;
    min-height: 16rem;
}

.wpapi-sec-jse:empty {
    display: none;
}

#wpapi-sec-json-pre {
    max-height: 60vh;
    overflow: auto;
}

#wpapi-sec-table td,
#wpapi-sec-probes td,
#wpapi-sec-scan td {
    min-width: 6rem;
}

/* A long segment without separators (route of a click) must not widen the whole table */
#wpapi-sec-scan td {
    overflow-wrap: anywhere;
}

.wpapi-sec-group:first-child {
    margin-top: 0 !important;
}

/* Phones: probe and scan rows as stacked blocks (four narrow columns squeezed the URLs to a
   few characters per line); each value keeps its column name.
   UI check phase 5: up to md (600 px: the masked examples of the scan sat behind the inner
   scroller, the probe column was 120 px wide) */
@media (max-width: 767.98px) {

    #wpapi-sec-probes thead,
    #wpapi-sec-scan thead {
        display: none;
    }

    #wpapi-sec-probes tr,
    #wpapi-sec-probes td,
    #wpapi-sec-scan tr,
    #wpapi-sec-scan td {
        display: block;
        min-width: 0;
        width: 100%;
    }

    #wpapi-sec-probes td.wpapi-num,
    #wpapi-sec-scan td.wpapi-num {
        text-align: left;
    }

    #wpapi-sec-probes td[data-label]::before,
    #wpapi-sec-scan td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--bs-secondary-color);
    }

    #wpapi-sec-probes td + td,
    #wpapi-sec-scan td + td {
        border-top: none;
        padding-top: 0;
    }

}

/* ------------------------------------------------------------------
   UI check phase 5 (P5-6, 2026-10-29)
   ------------------------------------------------------------------ */

/* Links to a finding inside the scan table start at the left like the text around them
   (a button centres its lines) */
#wpapi-sec-scan .wpapi-sec-goto {
    text-align: start;
}

/* Subject line of a card ("Where: /wp/v2/team/meta.email") wraps like the paths */
.wpapi-sec-subj {
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {

    /* Phones: the card body lost 1.75 rem on the left; evidence excerpts were 57 % of the screen */
    .wpapi-sec-detail {
        padding-left: 0.75rem;
    }

    .wpapi-sec-evidence {
        padding-left: 1rem;
    }

    /* Findings table as a stack per row: beside the level the finding had 80 px, one word per
       line. The ID is left out here (it stays in the card and in the reports); sorting stays reachable */
    #wpapi-sec-table,
    #wpapi-sec-table tbody,
    #wpapi-sec-table tr,
    #wpapi-sec-table td {
        display: block;
        width: 100%;
    }

    #wpapi-sec-table thead tr {
        display: flex;
        flex-wrap: wrap;
        gap: 0 .75rem;
    }

    #wpapi-sec-table td,
    #wpapi-sec-table th {
        min-width: 0;
        border: 0;
        padding: .125rem .25rem;
    }

    #wpapi-sec-table tbody tr {
        border-top: 1px solid var(--bs-border-color);
        padding: .375rem 0;
    }

    #wpapi-sec-table td.d-none {
        display: none;
    }

    #wpapi-sec-table td[data-label] {
        padding-left: 1.75rem;
    }

    #wpapi-sec-table td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--bs-secondary-color);
    }

    #wpapi-sec-table .wpapi-break,
    #wpapi-sec-table .wpapi-sec-goto {
        overflow-wrap: break-word;
    }

}

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

/* Masked example: its place in the data under the value, in plain words */
.wpapi-sec-path {
    font-size: inherit;
}

@media (max-width: 575.98px) {

    /* Title in its own line under the badges: the first word of a title ("A", "The") stood alone
       beside them */
    .wpapi-sec-item > summary .wpapi-sec-title {
        display: block;
    }

    /* Three frames (tab, card, list) squeezed the text to about 75 % of the width: the list loses
       its side borders and the card its side padding */
    #tab-security .card-body {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .wpapi-sec-list {
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }

}

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

/* Same square corners as the cards of the project */
.wpapi-sec-list {
    border-radius: 0;
}

.wpapi-sec-reason {
    margin-left: .5rem;
}

.wpapi-sec-fold > summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

.wpapi-sec-fold + .wpapi-sec-item,
.wpapi-sec-fold > div > .wpapi-sec-item:first-child {
    border-top: 1px solid var(--bs-border-color);
}

#wpapi-sec-q::placeholder {
    font-family: var(--bs-body-font-family);
}

#wpapi-sec-filters .form-check {
    align-self: center;
}

@media (max-width: 575.98px) {

    /* The reason under the title: flush with it and without an orphaned dash */
    .wpapi-sec-reason {
        display: block;
        margin-left: 0;
    }

    .wpapi-sec-dash {
        display: none;
    }

    /* Filter row: two equal columns under the search field; widths no longer depend on the site */
    #wpapi-sec-filters {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    #wpapi-sec-filters .wpapi-sec-qwrap,
    #wpapi-sec-filters .form-check {
        grid-column: 1 / -1;
    }

}

@media (max-width: 767.98px) {

    /* Probe rows: the path only, the host stands in the head of the card (full address in the log) */
    #wpapi-sec-probes .wpapi-sec-host {
        display: none;
    }

}

@media (min-width: 576px) {

    /* Level and Confidence: fixed widths, so the row does not jump from site to site */
    #wpapi-sec-level,
    #wpapi-sec-conf {
        width: 11rem;
    }

}
