/* ========================================= */
/* === Bytes (/bytes)                    === */
/* ========================================= */

.int-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: 12px;
}

.int-options[hidden] {
    display: none;
}

.int-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.int-options select {
    width: auto;
}

.bytes-summary {
    margin: 14px 0 6px;
    font-weight: bold;
}

.visual-root {
    overflow-x: auto;
}

.visual-root .error {
    color: var(--error);
    font-weight: bold;
}

.byte-table {
    width: 100%;
    border-collapse: collapse;
    font-family: Consolas, Menlo, monospace;
    font-size: 0.95rem;
    text-align: center;
}

.byte-table th {
    padding: 6px;
    background-color: var(--th-bg);
    color: var(--text-muted);
    font-family: Arial, sans-serif;
    font-weight: normal;
    font-size: 0.85rem;
    white-space: nowrap;
}

.byte-table td {
    padding: 5px 6px;
    border-top: 1px solid var(--border);
    white-space: nowrap;
}

.byte-table td small {
    color: var(--text-muted);
    font-family: Arial, sans-serif;
}

/* Every other character gets a tint, so the bytes of one character read as a group */
.byte-table tr.odd td {
    background-color: var(--surface-2);
}

.byte-table .char {
    font-family: Arial, sans-serif;
    font-size: 1.4rem;
    font-weight: bold;
}

.byte-table .code-point {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.byte-table tbody tr {
    transition: opacity 0.2s ease;
}

.byte-table tbody tr.pending {
    opacity: 0.08;
}

.bits {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.bit {
    width: 18px;
    line-height: 22px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background-color: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.bit.on {
    background-color: #007bff;
    border-color: #0062cc;
    color: #fff;
}

@media (max-width: 600px) {
    .bit {
        width: 14px;
        line-height: 18px;
        font-size: 0.7rem;
    }

    .byte-table td,
    .byte-table th {
        padding: 4px 3px;
    }
}

/* ========================================= */
/* === Hash table                        === */
/* ========================================= */

.hash-trace {
    margin-top: 14px;
    overflow-x: auto;
}

.hash-formula {
    margin: 6px 0;
    font-family: Consolas, Menlo, monospace;
    font-weight: bold;
}

.hash-steps {
    border-collapse: collapse;
    font-family: Consolas, Menlo, monospace;
    font-size: 0.85rem;
}

.hash-steps th,
.hash-steps td {
    padding: 3px 8px;
    border: 1px solid var(--border);
    text-align: center;
    white-space: nowrap;
}

.hash-steps th {
    background-color: var(--th-bg);
    color: var(--text-muted);
    font-family: Arial, sans-serif;
    font-weight: normal;
    text-align: left;
}

.hash-message {
    min-height: 1.4em;
    margin: 12px 0 8px;
}

.hash-message.error {
    color: var(--error);
    font-weight: bold;
}

.hash-buckets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 6px;
}

.bucket {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 56px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background-color: var(--card-bg);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.bucket.empty {
    background-color: var(--surface-2);
}

.bucket-index {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bucket-key {
    padding: 2px 4px;
    border-radius: 3px;
    background-color: #007bff;
    color: #fff;
    font-family: Consolas, Menlo, monospace;
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

.bucket-key.current {
    background-color: #d63384;
}

.bucket-key.tombstone {
    background-color: var(--secondary-bg);
    color: var(--text-muted);
    text-align: center;
}

/* The places an operation looked at: amber on the way, green or red where it ended */
.bucket.probed {
    border-color: #ffc107;
    background-color: rgba(255, 193, 7, 0.16);
}

.bucket.hit {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.18);
}

.bucket.miss {
    border-color: var(--error);
    background-color: rgba(176, 42, 55, 0.18);
}

/* ========================================= */
/* === Huffman coding                    === */
/* ========================================= */

.hf-progress {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hf-tree-wrap {
    overflow-x: auto;
    padding: 6px 0;
    text-align: center;
}

#huffman_tree {
    max-width: none;
}

.hf-edge {
    stroke: #9aa5b1;
    stroke-width: 1.5;
}

.hf-bit {
    fill: var(--text-muted);
    font: bold 12px Consolas, Menlo, monospace;
    text-anchor: middle;
}

.hf-node {
    fill: var(--card-bg);
    stroke: #6c757d;
    stroke-width: 2;
}

.hf-node.hf-new {
    fill: rgba(255, 193, 7, 0.35);
    stroke: #ffc107;
    stroke-width: 3;
}

.hf-weight {
    fill: var(--text);
    font: bold 12px Arial, sans-serif;
    text-anchor: middle;
}

.hf-char {
    fill: #fff;
    font: bold 16px Arial, sans-serif;
    text-anchor: middle;
}

.hf-count {
    fill: var(--text-muted);
    font: 11px Arial, sans-serif;
    text-anchor: middle;
}

.hf-code {
    fill: var(--text);
    font: bold 12px Consolas, Menlo, monospace;
    text-anchor: middle;
}

.hf-table {
    margin: 10px 0;
}

.hf-bits {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    font-family: Consolas, Menlo, monospace;
}

.hf-bits span {
    padding: 2px 5px;
    border-radius: 3px;
    color: #fff;
}

/* ========================================= */
/* === Bloom filter                      === */
/* ========================================= */

.bloom-bits {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 4px;
    margin-top: 14px;
}

.bloom-bit {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 0 4px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--card-bg);
    font-family: Consolas, Menlo, monospace;
}

.bloom-bit.on {
    background: #2471a3;
    border-color: #2471a3;
    color: #fff;
}

.bloom-bit.marked {
    box-shadow: 0 0 0 3px #ffc107;
}

.bloom-bit.zero {
    box-shadow: 0 0 0 3px #b02a37;
}

.bloom-index {
    font-size: 0.65rem;
    opacity: 0.7;
}

.bloom-hash {
    font-size: 0.65rem;
    font-weight: bold;
    color: #ffc107;
}

.bloom-bit:not(.on) .bloom-hash {
    color: #b8860b;
}

.bloom-answer {
    min-height: 1.4em;
    margin: 14px 0 6px;
    font-weight: bold;
}

.bloom-answer.no { color: #4caf50; }
.bloom-answer.maybe { color: var(--accent); }
.bloom-answer.false-positive { color: var(--error); }

.sha-hashes {
    display: grid;
    gap: 4px;
    margin: 14px 0;
}

.sha-hash-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sha-hex {
    font-family: Consolas, Menlo, monospace;
    font-size: 0.95rem;
    word-break: break-all;
    color: var(--text);
    margin-bottom: 6px;
}

.sha-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    margin: 8px 0 20px;
}

.sha-grid {
    display: grid;
    grid-template-columns: repeat(16, 14px);
    gap: 2px;
}

.sha-bit {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    vertical-align: middle;
}

.sha-bit.diff {
    background: #ffc107;
    border-color: #d39e00;
}

.sha-summary {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 0 0 8px;
}

.sha-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sha-error {
    color: var(--error);
}

.sha-chart {
    position: relative;
    max-width: 640px;
}

#sha_rounds {
    display: block;
    width: 100%;
    height: auto;
}

.sha-gridline {
    stroke: var(--border);
    stroke-width: 1;
    opacity: 0.6;
}

.sha-axis {
    stroke: var(--border);
    stroke-width: 1;
}

.sha-half {
    stroke: var(--text-muted);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.sha-half-label,
.sha-tick {
    fill: var(--text-muted);
    font-size: 11px;
}

.sha-half-label,
.sha-tick-y {
    text-anchor: end;
}

.sha-tick-x,
.sha-label {
    text-anchor: middle;
}

.sha-label {
    fill: var(--text-muted);
    font-size: 12px;
}

.sha-line {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2;
    stroke-linejoin: round;
}

.sha-cross {
    stroke: var(--text-muted);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.sha-dot {
    fill: var(--accent);
    stroke: var(--card-bg);
    stroke-width: 2;
}

.sha-hit {
    fill: transparent;
    cursor: crosshair;
}

.sha-tooltip {
    position: absolute;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    font-size: 0.85rem;
    white-space: nowrap;
    pointer-events: none;
}

.sha-details {
    margin-top: 10px;
}

.sha-details summary {
    cursor: pointer;
    color: var(--accent);
}

.sha-table {
    margin-top: 8px;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.sha-table th,
.sha-table td {
    padding: 2px 14px 2px 0;
    text-align: right;
}
