/* The look of the page visual.js builds. Every rule is under .jfile, so
   the block can sit inside another page. Colours are variables, with a
   dark set for a dark colour scheme. */

.jfile {
    --jf-page: #f4f4f4;
    --jf-panel: #fff;
    --jf-text: #302f2d;
    --jf-muted: #6f6e6b;
    --jf-line: #d5d3cf;
    --jf-accent: #1d4ed8;
    --jf-pick: #fff1b8;
    --jf-hot: #111;
    /* frame kinds */
    --jf-header: #4a4f5c;
    --jf-group: #2b6cd4;
    --jf-overflow: #1f9aa8;
    --jf-pointer: #8b53c6;
    --jf-body: #dd8a1c;
    --jf-free: #a9b3a2;
    /* field classes */
    --jf-link: #cfdcff;
    --jf-size: #bdebe3;
    --jf-count: #d2ecc4;
    --jf-time: #f6d3ea;
    --jf-flag: #f4e9a6;
    --jf-magic: #dcdce2;
    --jf-key: #ffc37d;
    --jf-bodyfield: #fdeccb;
    --jf-mark: #f7a9a2;
    --jf-textfield: #e4dcf7;
    container-type: inline-size;
    color: var(--jf-text);
    font: 14px/1.45 "Helvetica Neue", Helvetica, Arial, sans-serif;
    text-align: left;
}

@media (prefers-color-scheme: dark) {
    .jfile {
        --jf-page: #1c1b1a;
        --jf-panel: #252422;
        --jf-text: #e4e1dc;
        --jf-muted: #a3a09b;
        --jf-line: #413f3c;
        --jf-accent: #8ab4f8;
        --jf-pick: #5c4d0a;
        --jf-hot: #fff;
        --jf-header: #9aa1b3;
        --jf-group: #4f8fef;
        --jf-overflow: #2aa7b5;
        --jf-pointer: #a878e0;
        --jf-body: #e0962e;
        --jf-free: #5d6658;
        --jf-link: #2b3f7d;
        --jf-size: #1d5a52;
        --jf-count: #35592a;
        --jf-time: #6b2f56;
        --jf-flag: #5d5115;
        --jf-magic: #4a4a53;
        --jf-key: #8f4d0d;
        --jf-bodyfield: #4d3c1c;
        --jf-mark: #8c2c27;
        --jf-textfield: #45386f;
    }
}

.jfile *,
.jfile *::before {
    box-sizing: border-box;
}

.jfile button,
.jfile input,
.jfile select {
    font: inherit;
    color: inherit;
}

.jfile h3,
.jfile h4 {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
}

.jfile h4 {
    margin-top: 14px;
    font-size: 14px;
}

.jfile p {
    margin: 0 0 8px;
}

.jfile .jf-note,
.jfile .jf-hint,
.jfile .jf-more {
    color: var(--jf-muted);
    font-weight: normal;
}

.jfile .jf-number {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--jf-muted);
    white-space: nowrap;
}

/* The top row: type, sample, file. */

.jfile .jf-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    margin-bottom: 10px;
}

.jfile .jf-types {
    display: flex;
}

.jfile .jf-types button,
.jfile .jf-tabs button,
.jfile .jf-open,
.jfile .jf-find button {
    padding: 5px 14px;
    border: 1px solid var(--jf-line);
    background: var(--jf-panel);
    cursor: pointer;
}

.jfile .jf-types button + button,
.jfile .jf-tabs button + button {
    border-left: 0;
}

.jfile .jf-types button:first-child,
.jfile .jf-tabs button:first-child {
    border-radius: 5px 0 0 5px;
}

.jfile .jf-types button:last-child,
.jfile .jf-tabs button:last-child {
    border-radius: 0 5px 5px 0;
}

.jfile .jf-types button[aria-pressed="true"],
.jfile .jf-tabs button[aria-selected="true"] {
    background: var(--jf-text);
    border-color: var(--jf-text);
    color: var(--jf-panel);
}

.jfile .jf-open,
.jfile .jf-find button {
    border-radius: 5px;
}

.jfile select,
.jfile input[type="text"],
.jfile input[type="search"] {
    padding: 5px 8px;
    border: 1px solid var(--jf-line);
    border-radius: 5px;
    background: var(--jf-panel);
}

.jfile .jf-about {
    max-width: 90ch;
}

.jfile .jf-picture {
    margin-bottom: 10px;
}

.jfile .jf-picture summary {
    color: var(--jf-accent);
    cursor: pointer;
}

.jfile .jf-picture img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-top: 8px;
    border: 1px solid var(--jf-line);
    border-radius: 6px;
}

.jfile .jf-sample {
    display: block;
    color: var(--jf-muted);
}

.jfile .jf-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 22px;
    margin: 0 0 10px;
}

.jfile .jf-facts dt {
    color: var(--jf-muted);
    font-size: 12px;
}

.jfile .jf-facts dd {
    margin: 0;
    font-weight: 600;
}

.jfile .jf-problems {
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
}

.jfile .jf-problems li {
    padding: 6px 10px;
    border-left: 3px solid #c0392b;
    background: var(--jf-panel);
    margin-bottom: 4px;
}

.jfile .jf-box {
    min-width: 0;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--jf-line);
    border-radius: 6px;
    background: var(--jf-panel);
}

/* Frames: the map, the legend and the small squares used elsewhere. */

.jfile .jf-cell,
.jfile .jf-chip {
    --kind: var(--jf-panel);
    --fill: 100%;
    border: 1px solid color-mix(in srgb, var(--kind) 80%, var(--jf-text));
    border-radius: 3px;
    background: linear-gradient(to top, var(--kind) var(--fill), color-mix(in srgb, var(--kind) 30%, var(--jf-panel)) var(--fill));
    cursor: pointer;
}

.jfile .jf-k-header {
    --kind: var(--jf-header);
}

.jfile .jf-k-group {
    --kind: var(--jf-group);
}

.jfile .jf-k-overflow {
    --kind: var(--jf-overflow);
}

.jfile .jf-k-pointer {
    --kind: var(--jf-pointer);
}

.jfile .jf-k-body {
    --kind: var(--jf-body);
}

.jfile .jf-k-free {
    --kind: var(--jf-free);
    background: repeating-linear-gradient(45deg, var(--kind) 0 3px, color-mix(in srgb, var(--kind) 35%, var(--jf-panel)) 3px 6px);
}

.jfile .jf-k-unused {
    border: 1px dashed var(--jf-muted);
    background: none;
}

.jfile .jf-map {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-height: 260px;
    overflow-y: auto;
    padding: 3px;
}

.jfile .jf-map .jf-cell {
    width: 20px;
    height: 20px;
    padding: 0;
}

.jfile .jf-map.jf-dense .jf-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.jfile .jf-map .jf-chained,
.jfile .jf-map .jf-linked {
    outline: 2px solid color-mix(in srgb, var(--jf-text) 45%, transparent);
    outline-offset: 0;
}

.jfile .jf-map .jf-path {
    outline: 2px solid var(--jf-accent);
    outline-offset: 1px;
}

.jfile .jf-map .jf-selected,
.jfile .jf-chip.jf-selected {
    outline: 3px solid var(--jf-hot);
    outline-offset: 1px;
}

.jfile .jf-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--jf-muted);
}

.jfile .jf-legend i,
.jfile .jf-role i {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 5px;
    vertical-align: -1px;
    cursor: default;
}

.jfile .jf-readout {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--jf-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jfile .jf-chip {
    min-width: 24px;
    margin: 1px;
    padding: 0 4px;
    font: 11px/16px ui-monospace, Menlo, Consolas, monospace;
    color: #fff;
    text-shadow: 0 0 2px #000;
}

.jfile .jf-chip.jf-k-unused {
    color: var(--jf-text);
    text-shadow: none;
}

/* Two columns: the structure of the file, and one frame. */

.jfile .jf-columns {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 12px;
    align-items: start;
}

@container (max-width: 980px) {
    .jfile .jf-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

.jfile .jf-tabs {
    display: flex;
    margin-bottom: 10px;
}

.jfile .jf-pane {
    max-height: 520px;
    overflow: auto;
}

.jfile .jf-pane h4:first-child {
    margin-top: 0;
}

.jfile .jf-pane ul {
    margin: 0;
    padding-left: 16px;
    list-style: none;
}

.jfile .jf-pane > ul {
    padding-left: 0;
}

.jfile .jf-pane li {
    padding: 2px 0;
}

.jfile .jf-pane li ul {
    border-left: 1px solid var(--jf-line);
    margin-left: 4px;
}

.jfile .jf-empty {
    color: var(--jf-muted);
}

.jfile .jf-node,
.jfile td button,
.jfile .jf-part button,
.jfile .jf-try button {
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}

.jfile button.jf-node,
.jfile td button,
.jfile .jf-part button,
.jfile .jf-try button {
    color: var(--jf-accent);
}

.jfile button.jf-node:hover,
.jfile td button:hover,
.jfile .jf-part button:hover,
.jfile .jf-try button:hover {
    text-decoration: underline;
}

.jfile table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.jfile th,
.jfile td {
    padding: 3px 8px 3px 0;
    border-bottom: 1px solid var(--jf-line);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.jfile thead th {
    position: sticky;
    top: 0;
    background: var(--jf-panel);
    color: var(--jf-muted);
    font-size: 12px;
    font-weight: normal;
    white-space: nowrap;
    overflow-wrap: normal;
}

.jfile .jf-filter {
    width: 100%;
    margin-bottom: 8px;
}

.jfile .jf-find {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.jfile .jf-find input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

.jfile .jf-steps {
    margin: 0;
    padding-left: 22px;
}

.jfile .jf-steps li {
    margin-bottom: 8px;
}

.jfile .jf-go {
    cursor: pointer;
}

.jfile .jf-go:hover {
    color: var(--jf-accent);
}

.jfile .jf-record:not(:empty) {
    margin-top: 12px;
    border-top: 1px solid var(--jf-line);
}

.jfile .jf-body {
    max-height: 220px;
    overflow: auto;
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--jf-page);
    font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
}

/* One frame: its fields, then its bytes. */

.jfile .jf-role {
    margin-bottom: 6px;
}

.jfile .jf-chain:not(:empty) {
    margin-bottom: 8px;
}

.jfile .jf-fields {
    max-height: 300px;
    overflow: auto;
    margin-bottom: 10px;
}

.jfile .jf-fields td i {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
}

.jfile .jf-part th {
    padding-top: 8px;
    font-weight: 600;
}

.jfile .jf-c-link {
    background: var(--jf-link);
}

.jfile .jf-c-size {
    background: var(--jf-size);
}

.jfile .jf-c-count {
    background: var(--jf-count);
}

.jfile .jf-c-time {
    background: var(--jf-time);
}

.jfile .jf-c-flag {
    background: var(--jf-flag);
}

.jfile .jf-c-magic {
    background: var(--jf-magic);
}

.jfile .jf-c-key {
    background: var(--jf-key);
}

.jfile .jf-c-body {
    background: var(--jf-bodyfield);
}

.jfile .jf-c-mark {
    background: var(--jf-mark);
}

.jfile .jf-c-text {
    background: var(--jf-textfield);
}

.jfile .jf-c-stale {
    background: repeating-linear-gradient(45deg, var(--jf-magic) 0 2px, transparent 2px 5px);
}

.jfile .jf-c-none {
    color: var(--jf-muted);
}

.jfile .jf-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 6px;
    font-size: 11px;
}

.jfile .jf-swatches span {
    padding: 1px 6px;
    border-radius: 3px;
}

.jfile .jf-hex {
    max-height: 460px;
    overflow: auto;
    padding: 6px 8px;
    border-radius: 4px;
    background: var(--jf-page);
    font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
    white-space: pre;
}

.jfile .jf-hex b {
    font-weight: normal;
}

.jfile .jf-hex .jf-first {
    box-shadow: inset 2px 0 var(--jf-page);
}

.jfile .jf-at {
    margin-right: 2ch;
    color: var(--jf-muted);
}

.jfile .jf-bytes {
    display: inline-block;
    min-width: 50ch;
}

.jfile .jf-fold {
    color: var(--jf-muted);
    font-style: italic;
}

.jfile .jf-hex .jf-hot,
.jfile .jf-hex .jf-focus {
    background: var(--jf-hot);
    color: var(--jf-panel);
}

.jfile .jf-fields tr.jf-hot td,
.jfile .jf-fields tr.jf-focus td {
    background: var(--jf-pick);
}
