/**
 * WP REST API Explorer - Reports tab (plan 09 §9)
 *
 * @package   JPKCom_Tools
 * @subpackage WP_API
 */

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

/* Preview and Markdown share one frame */
.wpapi-rp-preview,
.wpapi-rp-source {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: var(--bs-body-bg);
    padding: 1rem;
}

.wpapi-rp-preview:focus,
.wpapi-rp-preview:focus-visible {
    outline: none;
}

/* The Markdown exactly as Copy and Download give it */
.wpapi-rp-source {
    margin: 0;
    font-size: .8125rem;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-height: 80vh;
    overflow: auto;
}

/* Reading width for running text; tables and code use the whole frame */
.wpapi-rp-preview p,
.wpapi-rp-preview ul,
.wpapi-rp-preview ol,
.wpapi-rp-preview blockquote {
    max-width: 52rem;
}

.wpapi-rp-preview > :last-child {
    margin-bottom: 0;
}

/* Report levels: "#" and "##" sit below the page's own headings (report-ui.js moves them down by
   two levels); the look follows the outline of the report, not the tag */
.wpapi-rp-preview h3 {
    font-size: 1.25rem;
    margin: 0 0 .75rem;
}

.wpapi-rp-preview h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    margin: 1.5rem 0 .5rem;
    padding-top: .75rem;
    border-top: 1px solid var(--bs-border-color);
}

.wpapi-rp-preview h5 {
    font-size: .9375rem;
    font-weight: 600;
    margin: 1rem 0 .5rem;
}

/* The title of a finding is not smaller than the lines below it */
.wpapi-rp-preview h6 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1rem 0 .25rem;
}

.wpapi-rp-preview h5,
.wpapi-rp-preview h6,
.wpapi-rp-preview li,
.wpapi-rp-preview td,
.wpapi-rp-preview p {
    overflow-wrap: break-word;
}

.wpapi-rp-preview blockquote {
    border-left: 3px solid var(--bs-border-color);
    color: var(--bs-secondary-color);
    margin: 0 0 1rem;
    padding-left: .75rem;
}

.wpapi-rp-preview blockquote > :last-child {
    margin-bottom: 0;
}

/* Quoted site text and evidence stay inside the frame; a long route must not widen the page */
.wpapi-rp-preview pre {
    background: var(--bs-tertiary-bg);
    border-radius: var(--bs-border-radius-sm);
    font-size: .8125rem;
    max-height: 24rem;
    overflow: auto;
    padding: .5rem .75rem;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

/* A path breaks at the <wbr> after its slashes; only a value too long for the frame anywhere else */
.wpapi-rp-preview code {
    overflow-wrap: break-word;
}

.wpapi-rp-preview pre code {
    overflow-wrap: anywhere;
}

/* Sentences and words of the tool read as text; code style stays for paths, IDs, headers and values */
.wpapi-rp-preview code.wpapi-rp-words {
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

/* The IDs of the OK list step back behind their sentences */
.wpapi-rp-preview code.wpapi-rp-okid {
    color: var(--bs-secondary-color);
    font-size: .75rem;
}

.wpapi-rp-preview h5 .badge {
    font-size: .8125rem;
}

/* Without a floor the browser squeezes text columns to a few letters per line */
.wpapi-rp-preview td:not(.text-end) {
    min-width: 7rem;
}

.wpapi-rp-preview td:first-child {
    min-width: 13rem;
}

.wpapi-rp-preview td:has(code) {
    min-width: 9.5rem;
}

/* The block for AI tools: there, but out of the reader's way */
.wpapi-rp-meta {
    margin-bottom: 1rem;
}

.wpapi-rp-meta > summary {
    color: var(--bs-secondary-color);
    cursor: pointer;
    font-size: .875rem;
}

/* Collections that were not read: one line per reason, their routes one click away (round 5) */
.wpapi-rp-notread {
    margin-bottom: .5rem;
    font-size: .875rem;
}

.wpapi-rp-notread > ul {
    margin: .25rem 0 0;
    padding-left: 1.25rem;
}

.wpapi-rp-meta > pre {
    margin: .5rem 0 0;
}

.wpapi-rp-probes {
    padding-left: 1.25rem;
}

.wpapi-rp-probes code {
    overflow-wrap: anywhere;
}

/* A sentence of facts per row: on phones label above value, the column would squeeze the value */
@media (max-width: 575.98px) {

    #wpapi-rp-facts th,
    #wpapi-rp-facts td {
        display: block;
        border: 0;
        padding: 0;
    }

    #wpapi-rp-facts tr {
        display: block;
        padding: .25rem 0;
        border-bottom: 1px solid var(--bs-border-color);
    }

    #wpapi-rp-facts tr:last-child {
        border-bottom: 0;
    }

    .wpapi-rp-preview,
    .wpapi-rp-source {
        padding: .75rem;
    }

    /* Tables of a report as stacked rows: every column stays in view, no sideways wipe. Each cell
       names its column (data-label, report-ui.js). A compact table (few columns, short values,
       report-ui.js COMPACT_TABLE) stays a table */
    .wpapi-rp-preview table:not(.wpapi-rp-compact) thead {
        display: none;
    }

    .wpapi-rp-preview table:not(.wpapi-rp-compact),
    .wpapi-rp-preview table:not(.wpapi-rp-compact) tbody,
    .wpapi-rp-preview table:not(.wpapi-rp-compact) tr,
    .wpapi-rp-preview table:not(.wpapi-rp-compact) td {
        display: block;
        width: 100%;
    }

    .wpapi-rp-preview table:not(.wpapi-rp-compact) tr {
        padding: .375rem 0;
        border-bottom: 1px solid var(--bs-border-color);
    }

    .wpapi-rp-preview table:not(.wpapi-rp-compact) td,
    .wpapi-rp-preview table:not(.wpapi-rp-compact) td:not(.text-end),
    .wpapi-rp-preview table:not(.wpapi-rp-compact) td:first-child,
    .wpapi-rp-preview table:not(.wpapi-rp-compact) td:has(code) {
        min-width: 0;
        padding: .0625rem 0;
        border: 0;
        background: none;
        text-align: start;
    }

    /* Stacked rows: numbers start at the left like every other line (text-end has !important) */
    .wpapi-rp-preview table:not(.wpapi-rp-compact) td.text-end {
        text-align: start !important;
    }

    .wpapi-rp-preview table:not(.wpapi-rp-compact) td[data-label]::before {
        content: attr(data-label) ": ";
        color: var(--bs-secondary-color);
    }

    /* A short label needs no wide first column on a phone (9rem: a code span stays readable) */
    .wpapi-rp-preview table.wpapi-rp-compact td:first-child {
        min-width: 9rem;
    }

    /* Two rows of toggles at full width instead of half-empty lines */
    #wpapi-rp-bar > .btn-group {
        width: 100%;
    }

    #wpapi-rp-bar > .btn-group > .btn {
        flex: 1 1 0;
    }

}

/* Empty until a send has something to say */
#wpapi-rp-send-msg:empty {
    display: none;
}

/* A locked button must look locked; it keeps the focus (aria-disabled, not disabled) */
#wpapi-rp-pack[aria-disabled="true"],
#wpapi-rp-send-probes[aria-disabled="true"] {
    opacity: .65;
    cursor: not-allowed;
}

/* Image review 2026-11-16: next to the taller "Report pack" the cover card stretched to its height
   and showed an empty field under its table; it ends with its content (h-100 has !important)
   [Claude: natural height instead of a stretched card] */
#tab-report .card[aria-labelledby="wpapi-rp-cover-title"] {
    height: auto !important;
}
