/* =========================================================
   ToolZen Hub
   JSON Formatter & Validator

   Only what the shared tool styles do not already provide: the
   two-box workspace, the status and error panel. Buttons, focus
   and headings come from the shared layer. Loaded after
   calculator-responsive.css.

   Valid, invalid and unchecked are told in words ("Valid JSON",
   "Not valid JSON"), never by colour alone. Nothing animates.

   Narrow screens stack: input, buttons, status, output.
   From 1000px the output sits beside the input and its buttons.
========================================================= */

.jf-workspace [hidden] {

    display: none !important;

}

.jf-workspace {

    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;

}

.jf-pane {

    display: flex;
    flex-direction: column;

    min-width: 0;

}

.jf-pane__head {

    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;

    margin-bottom: 8px;

}

.jf-label {

    color: var(--color-ink);

    font-size: 15px;
    font-weight: 700;

}

.jf-meta {

    color: #475467;

    font-size: 13px;
    font-variant-numeric: tabular-nums;

}

.jf-text {

    display: block;

    width: 100%;
    min-height: 280px;
    flex: 1;

    padding: 12px 14px;

    border: 1px solid #d0d5dd;
    border-radius: 12px;

    background: #ffffff;

    color: var(--color-ink);

    font-family:
        ui-monospace, SFMono-Regular, Menlo, Consolas,
        "Liberation Mono", monospace;
    font-size: 14px;
    line-height: 1.55;
    tab-size: 2;

    white-space: pre;
    overflow: auto;
    resize: vertical;

}

.jf-text[readonly] {

    background: #f9fafb;

}

.jf-text:focus-visible {

    outline: 3px solid var(--color-action-green);
    outline-offset: 2px;

}

.jf-text[aria-invalid="true"] {

    border-color: #b42318;
    border-width: 2px;
    padding: 11px 13px;

}

.jf-hint {

    margin: 8px 0 0;

    color: #475467;

    font-size: 14px;

}

.jf-link {

    padding: 0;

    border: 0;
    background: none;

    color: var(--color-action-green);

    font: inherit;
    font-weight: 600;
    text-decoration: underline;

    cursor: pointer;

}

.jf-link:focus-visible {

    outline: 3px solid var(--color-action-green);
    outline-offset: 2px;

}

/* buttons: Format is the main action; two columns on a phone, one row on a wide screen */

.jf-actions {

    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;

}

.jf-button {

    min-width: 0;
    min-height: 48px;

    font-size: 16px;

}

#jf-format {

    grid-column: 1 / -1;

}

.jf-keys {

    grid-column: 1 / -1;

    margin: 2px 0 0;

    color: #475467;

    font-size: 13px;
    line-height: 1.7;
    text-align: center;

}

.jf-keys kbd {

    padding: 1px 6px;

    border: 1px solid #d0d5dd;
    border-radius: 6px;

    background: #f9fafb;

    color: var(--color-ink);

    font: inherit;
    font-size: 12px;
    font-weight: 600;

}

/* status and error */

.jf-result {

    min-width: 0;

}

.jf-status {

    margin: 0;
    padding: 10px 14px;

    border: 1px solid var(--color-slate-200);
    border-left-width: 6px;
    border-radius: 10px;

    background: #f9fafb;

    color: #344054;

    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;

    overflow-wrap: anywhere;

}

.jf-workspace[data-state="valid"] .jf-status {

    border-color: #067647;

    background: #ecfdf3;

    color: #05603a;

}

.jf-workspace[data-state="invalid"] .jf-status {

    border-color: #b42318;

    background: #fef3f2;

    color: #912018;

}

.jf-error {

    margin-top: 12px;
    padding: 14px;

    border: 1px solid #fda29b;
    border-radius: 12px;

    background: #ffffff;

}

.jf-error[data-stale="true"] {

    border-style: dashed;

}

.jf-error p {

    margin: 0;

}

.jf-error__title {

    color: #912018;

    font-size: 16px;
    font-weight: 700;

}

.jf-error__stale {

    color: #475467;

    font-size: 13px;
    font-weight: 400;

}

.jf-error__message {

    margin-top: 6px !important;

    color: var(--color-ink);

    font-size: 15px;
    line-height: 1.55;

    overflow-wrap: anywhere;

}

.jf-error__where {

    margin-top: 6px !important;

    color: #475467;

    font-size: 14px;
    font-variant-numeric: tabular-nums;

}

.jf-error__context {

    max-width: 100%;
    margin: 10px 0 12px;
    padding: 10px 12px;

    border-radius: 8px;

    background: #f9fafb;

    color: var(--color-ink);

    font-family:
        ui-monospace, SFMono-Regular, Menlo, Consolas,
        "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.5;

    white-space: pre;
    overflow-x: auto;

}

.jf-error__context:focus-visible {

    outline: 3px solid var(--color-action-green);
    outline-offset: 2px;

}

.jf-goto {

    min-height: 44px;

}

.jf-notes {

    margin: 12px 0 0;
    padding: 10px 14px 10px 32px;

    border: 1px solid var(--color-slate-200);
    border-radius: 10px;

    background: #ffffff;

    color: #344054;

    font-size: 14px;
    line-height: 1.55;

    overflow-wrap: anywhere;

}

.jf-sr-only {

    position: absolute;

    width: 1px;
    height: 1px;

    margin: -1px;
    padding: 0;

    overflow: hidden;

    clip: rect(0, 0, 0, 0);

    white-space: nowrap;

    border: 0;

}

/* a phone: 16px text so the browser does not zoom the page when the box is focused */

@media (max-width: 640px) {

    .jf-text {

        min-height: 220px;

        font-size: 16px;

    }

}

/* wider screens: buttons in one row; the output beside the input */

@media (min-width: 640px) {

    /* as many buttons per row as fit (three in the half-width column beside the output), never wider than the column */
    .jf-actions {

        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));

    }

    #jf-format {

        grid-column: auto;

    }

    .jf-button {

        padding-inline: 12px;

    }

    .jf-keys {

        grid-column: 1 / -1;

        text-align: left;

    }

}

@media (min-width: 1000px) {

    .jf-workspace {

        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "input  output"
            "actions output"
            "result output";
        grid-template-rows: auto auto 1fr;
        column-gap: 24px;

        align-items: start;

    }

    .jf-pane--input {

        grid-area: input;

    }

    .jf-actions {

        grid-area: actions;

    }

    .jf-result {

        grid-area: result;

    }

    .jf-pane--output {

        grid-area: output;

        align-self: stretch;

    }

    .jf-text {

        min-height: 360px;

    }

    .jf-pane--output .jf-text {

        resize: none;

    }

}
