/* API Tester (/api-tester): only what is the app's own (the request line, the key / value rows, the status pill, the
   JSON tree and the history). Panels, tiles, fields, buttons, tables and colours come from the app kit (css/app-kit,
   docs/app-kit.md). Loaded only on this app's page (StylePaths in its demo catalog entry). */

/* On a phone the site's photo-app rule sets align-items: start on every stage, which beats the kit's stretch. */
.api-tester-landing-app > .ak-stage > * {
    align-self: stretch;
    min-width: 0;
}

/* The method colours (GET green, POST orange, PUT blue, PATCH purple, DELETE red) and the JSON value colours. */
.api-tester-landing-app {
    --at-get: var(--ak-success);
    --at-post: var(--ak-warning);
    --at-put: var(--ak-info);
    --at-patch: var(--ak-series-6);
    --at-delete: var(--ak-danger);
    --at-other: var(--ak-muted);
    --at-string: var(--ak-success);
    --at-number: var(--ak-series-1);
    --at-boolean: var(--ak-series-4);
    --at-key: var(--ak-text);
}

/* --- The request line: method, URL, Send ----------------------------------------------------------------------- */

.api-tester-landing-app .at-bar {
    display: flex;
    gap: var(--ak-space-2);
    align-items: stretch;
    min-width: 0;
}

.api-tester-landing-app .at-method {
    flex: 0 0 auto;
    width: auto;
    min-width: 6.5rem;
    font-family: var(--ak-font-mono);
    font-weight: 700;
    color: var(--at-other);
}

.api-tester-landing-app .at-method[data-method="GET"] { color: var(--at-get); }
.api-tester-landing-app .at-method[data-method="POST"] { color: var(--at-post); }
.api-tester-landing-app .at-method[data-method="PUT"] { color: var(--at-put); }
.api-tester-landing-app .at-method[data-method="PATCH"] { color: var(--at-patch); }
.api-tester-landing-app .at-method[data-method="DELETE"] { color: var(--at-delete); }

.api-tester-landing-app .at-method option {
    color: var(--ak-text);
}

.api-tester-landing-app .at-url {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
}

.api-tester-landing-app .at-send {
    flex: 0 0 auto;
}

.api-tester-landing-app .at-send.is-busy {
    background: var(--ak-danger);
    border-color: var(--ak-danger);
}

.api-tester-landing-app .at-send.is-busy .ak-icon {
    display: none;
}

/* --- Request tabs ------------------------------------------------------------------------------------------------ */

.api-tester-landing-app .at-req,
.api-tester-landing-app .at-res {
    gap: var(--ak-space-3);
}

.api-tester-landing-app .at-tabs {
    align-self: flex-start;
}

/* The URL and the key / value fields in the code font (the kit's input rule resets the font, so match its weight). */
.api-tester-landing-app :is(.at-bar, .at-kv-row) input.ak-field:not([type="color"]):not([type="range"]):not([type="checkbox"]):not([type="file"]) {
    font-family: var(--ak-font-mono);
}

.api-tester-landing-app .at-count {
    font-weight: 500;
    opacity: 0.85;
}

.api-tester-landing-app .at-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.api-tester-landing-app .at-panel {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
    min-width: 0;
}

.api-tester-landing-app .at-panel[hidden],
.api-tester-landing-app [hidden] {
    display: none !important;
}

/* Key / value rows: a checkbox, the key, the value, remove, and for headers a "set by the browser" tag. */
.api-tester-landing-app .at-kv {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.api-tester-landing-app .at-kv-row {
    display: grid;
    grid-template-columns: auto minmax(0, 2fr) minmax(0, 3fr) auto;
    gap: 0.4rem;
    align-items: center;
}

.api-tester-landing-app .at-kv-row .ak-field {
    min-width: 0;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
}

.api-tester-landing-app .at-kv-row.is-blank .at-kv-del {
    visibility: hidden;
}

.api-tester-landing-app .at-kv-row:has(.at-kv-on:not(:checked)) .ak-field {
    opacity: 0.55;
}

.api-tester-landing-app .at-kv-on {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--ak-accent);
}

.api-tester-landing-app .at-kv-tag {
    grid-column: 2 / -1;
    justify-self: start;
}

.api-tester-landing-app .at-autos {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.api-tester-landing-app .at-auto {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.6rem;
    padding: 0.3rem 0.6rem;
    border: 1px dashed var(--ak-border);
    border-radius: var(--ak-radius-sm);
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    direction: ltr;
}

.api-tester-landing-app .at-auto-k {
    color: var(--ak-text);
    font-weight: 600;
}

.api-tester-landing-app .at-auto-v {
    overflow-wrap: anywhere;
}

.api-tester-landing-app .at-body-head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-2);
    align-items: center;
    justify-content: space-between;
}

.api-tester-landing-app .at-body {
    min-height: 9rem;
    resize: vertical;
    direction: ltr;
}

.api-tester-landing-app .at-check {
    margin: 0;
    font-size: var(--ak-fs-sm);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.api-tester-landing-app .at-check.is-valid { color: var(--ak-success); }
.api-tester-landing-app .at-check.is-invalid { color: var(--ak-danger); }

.api-tester-landing-app .at-auth-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
    gap: var(--ak-space-2);
}

.api-tester-landing-app .at-auth-preview {
    display: block;
    padding: 0.4rem 0.6rem;
    border-radius: var(--ak-radius-sm);
    background: var(--ak-hover);
    color: var(--ak-muted);
    font-size: var(--ak-fs-sm);
    overflow-wrap: anywhere;
}

/* --- Response: status pill, meta, tools, body and headers ------------------------------------------------------ */

.api-tester-landing-app .at-res-head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-2) var(--ak-space-3);
    align-items: center;
    min-height: 2.2rem;
}

.api-tester-landing-app .at-res-tools {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-2);
    align-items: center;
    margin-inline-start: auto;
}

.api-tester-landing-app .at-status {
    --at-st: var(--ak-muted);
    padding: 0.2rem 0.75rem;
    border-radius: var(--ak-radius-pill);
    background: color-mix(in srgb, var(--at-st) 15%, var(--ak-bg));
    color: color-mix(in srgb, var(--at-st) 80%, var(--ak-text));
    font-family: var(--ak-font-mono);
    font-weight: 700;
    white-space: nowrap;
}

.api-tester-landing-app .at-status--2xx { --at-st: var(--ak-success); }
.api-tester-landing-app .at-status--3xx { --at-st: var(--ak-info); }
.api-tester-landing-app .at-status--4xx { --at-st: var(--ak-warning); }
.api-tester-landing-app .at-status--5xx { --at-st: var(--ak-danger); }

.api-tester-landing-app .at-res-meta {
    gap: 0.25rem 0.9rem;
}

.api-tester-landing-app .at-meta-name::after {
    content: ": ";
}

.api-tester-landing-app .at-pending {
    color: var(--ak-muted);
    font-style: italic;
}

.api-tester-landing-app .at-empty {
    margin: 0;
    padding: var(--ak-space-4) var(--ak-space-3);
    text-align: center;
    color: var(--ak-muted);
}

.api-tester-landing-app .at-error {
    align-items: flex-start;
    line-height: 1.5;
}

.api-tester-landing-app .at-view {
    max-height: 70vh;
    overflow: auto;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--ak-border);
    border-radius: var(--ak-radius-sm);
    background: var(--ak-bg);
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-sm);
    line-height: 1.55;
    direction: ltr;
    text-align: left;
}

.api-tester-landing-app .at-pre {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font: inherit;
}

.api-tester-landing-app .at-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.api-tester-landing-app .at-headers th {
    width: 35%;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.api-tester-landing-app .at-headers td {
    overflow-wrap: anywhere;
}

/* The JSON tree: formatted JSON with a toggle on every object and array, collapsed ones show their size. */
.api-tester-landing-app .at-json,
.api-tester-landing-app .at-jc {
    margin: 0;
    padding: 0;
    list-style: none;
}

.api-tester-landing-app .at-jc {
    padding-left: 1.4em;
}

.api-tester-landing-app .at-jn {
    position: relative;
    overflow-wrap: anywhere;
}

.api-tester-landing-app .at-jt,
.api-tester-landing-app .at-jpad {
    display: inline-block;
    width: 1.2em;
    margin-left: -0.15em;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ak-muted);
    font: inherit;
    line-height: inherit;
    text-align: center;
    cursor: pointer;
}

.api-tester-landing-app .at-jpad {
    cursor: default;
}

.api-tester-landing-app .at-jt:hover,
.api-tester-landing-app .at-jt:focus-visible {
    color: var(--ak-accent);
}

.api-tester-landing-app .at-jk { color: var(--at-key); font-weight: 600; }
.api-tester-landing-app .at-jp { color: var(--ak-muted); }
.api-tester-landing-app .at-jv-string { color: var(--at-string); }
.api-tester-landing-app .at-jv-number { color: var(--at-number); }
.api-tester-landing-app .at-jv-boolean { color: var(--at-boolean); }
.api-tester-landing-app .at-jv-null { color: var(--ak-muted); font-style: italic; }
.api-tester-landing-app .at-jv-object,
.api-tester-landing-app .at-jv-array { color: var(--ak-muted); }

.api-tester-landing-app .at-jsum {
    display: none;
    margin: 0 0.4em;
    padding: 0 0.4em;
    border-radius: var(--ak-radius-pill);
    background: var(--ak-hover);
    color: var(--ak-muted);
    font-size: 0.9em;
}

.api-tester-landing-app .at-jn.is-closed > .at-jc {
    display: none;
}

.api-tester-landing-app .at-jn.is-closed > .at-jsum {
    display: inline;
}

.api-tester-landing-app .at-jclose {
    display: block;
    padding-left: 1.05em;
}

.api-tester-landing-app .at-jn.is-closed > .at-jclose {
    display: inline;
    padding-left: 0;
}

/* --- Control panel: the history ---------------------------------------------------------------------------------- */

.api-tester-landing-app .at-history {
    display: flex;
    flex-direction: column;
    gap: var(--ak-space-2);
    min-width: 0;
}

.api-tester-landing-app .at-history-head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ak-space-2);
    align-items: center;
    justify-content: space-between;
}

.api-tester-landing-app .at-history-head .filter-landing-controls-label {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
}

.api-tester-landing-app .at-history-list {
    max-height: 24rem;
    overflow: auto;
}

.api-tester-landing-app .at-hist {
    padding: 0;
}

.api-tester-landing-app .at-hist-btn {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    width: 100%;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: start;
    cursor: pointer;
}

.api-tester-landing-app .at-hist-btn .ak-item-title {
    white-space: nowrap;
    font-family: var(--ak-font-mono);
    font-weight: 500;
}

.api-tester-landing-app .at-m {
    flex: 0 0 3.6rem;
    font-family: var(--ak-font-mono);
    font-size: var(--ak-fs-xs);
    font-weight: 700;
    color: var(--at-other);
}

.api-tester-landing-app .at-m--get { color: var(--at-get); }
.api-tester-landing-app .at-m--post { color: var(--at-post); }
.api-tester-landing-app .at-m--put { color: var(--at-put); }
.api-tester-landing-app .at-m--patch { color: var(--at-patch); }
.api-tester-landing-app .at-m--delete { color: var(--at-delete); }

.api-tester-landing-app .at-hs {
    color: var(--at-st, var(--ak-muted));
    font-family: var(--ak-font-mono);
    font-weight: 700;
}

.api-tester-landing-app .at-hs--err { --at-st: var(--ak-danger); }

/* --- Phones: the request line wraps, the URL gets its own line ---------------------------------------------------- */

@media (max-width: 640px) {
    .api-tester-landing-app .at-bar {
        flex-wrap: wrap;
    }

    .api-tester-landing-app .at-url {
        order: 3;
        flex-basis: 100%;
    }

    .api-tester-landing-app .at-method {
        flex: 1 1 auto;
    }

    .api-tester-landing-app .at-kv-row {
        grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
        gap: 0.3rem;
    }

    .api-tester-landing-app .at-res-tools {
        margin-inline-start: 0;
    }

    .api-tester-landing-app .at-tabs .ak-seg-btn {
        padding-inline: 0.5rem;
    }
}

/* Remove on a row: quiet until hovered. */
.api-tester-landing-app.ak-app > .filter-landing-stage .at-kv-row .ak-btn.at-kv-del {
    border-color: transparent;
    background: transparent;
    color: var(--ak-muted);
}

.api-tester-landing-app.ak-app > .filter-landing-stage .at-kv-row .ak-btn.at-kv-del:hover:not(:disabled),
.api-tester-landing-app.ak-app > .filter-landing-stage .at-kv-row .ak-btn.at-kv-del:focus-visible {
    background: color-mix(in srgb, var(--ak-danger) 12%, transparent);
    color: var(--ak-danger);
}
