/* Styles for the interactive figures in the Tree-Ring post. Uses tabi / site variables. */

.tr-widget {
    margin: 2rem 0;
    border: 1px solid var(--divider-color);
    border-radius: 0.6rem;
    background: var(--bg-2);
    padding: 1rem 1.1rem 1.1rem;
    font-size: 0.92rem;
    line-height: 1.5;
}

.tr-widget-title {
    margin: 0 0 0.75rem;
    color: var(--text-color-high-contrast);
    font-weight: 600;
    font-size: 0.95rem;
}

.tr-row { display: grid; gap: 0.75rem; align-items: start; }
.tr-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tr-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tr-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tr-lab { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0.75rem; }

.tr-fig { margin: 0; text-align: center; }
.tr-fig figcaption {
    margin-top: 0.3rem;
    color: var(--meta-color);
    font-size: 0.78rem;
    font-family: var(--mono-font, monospace);
    line-height: 1.3;
}
.tr-canvas {
    display: block;
    border-radius: 0.3rem;
    background: #000;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.tr-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.2rem;
    align-items: center;
    margin-top: 0.9rem;
}

.tr-slider {
    display: flex;
    flex: 1 1 16rem;
    gap: 0.6rem;
    align-items: center;
    margin: 0;
}
.tr-slider-label { color: var(--text-color); white-space: nowrap; }
.tr-slider input[type="range"] { flex: 1; accent-color: var(--text-color-high-contrast); min-width: 6rem; }
.tr-val {
    min-width: 7.5rem;
    color: var(--text-color-high-contrast);
    font-size: 0.82rem;
    font-family: var(--mono-font, monospace);
}

.tr-strength { display: flex; flex: 1 1 24rem; gap: 0.6rem; align-items: center; }

.tr-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.tr-chip, .tr-btn {
    cursor: pointer;
    border: 1px solid var(--divider-color);
    border-radius: 999px;
    background: transparent;
    padding: 0.2rem 0.7rem;
    color: var(--text-color);
    font: inherit;
    font-size: 0.82rem;
}
.tr-chip:hover, .tr-btn:hover { border-color: var(--text-color); }
.tr-chip.on {
    border-color: var(--text-color-high-contrast);
    background: var(--text-color-high-contrast);
    color: var(--background-color);
}
.tr-paper { font-family: var(--mono-font, monospace); white-space: nowrap; }

.tr-caption, .tr-stats, .tr-foot, .tr-sub {
    margin: 0.75rem 0 0;
    color: var(--meta-color);
    font-size: 0.85rem;
}
.tr-foot { font-size: 0.8rem; }
.tr-sub { margin: 0.6rem 0 0.35rem; }

.tr-card {
    border: 1px solid var(--divider-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
}
.tr-card h4 {
    margin: 0 0 0.6rem;
    color: var(--text-color-high-contrast);
    font-size: 0.9rem;
}
.tr-card .tr-row + .tr-row { margin-top: 0.5rem; }
.tr-small figcaption { font-size: 0.72rem; }

.tr-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    align-items: center;
    margin-top: 0.7rem;
    font-size: 0.85rem;
    font-family: var(--mono-font, monospace);
}
.tr-metric { color: var(--text-color-high-contrast); }
.tr-verdict {
    border-radius: 999px;
    padding: 0.05rem 0.6rem;
    font-weight: 600;
    font-size: 0.78rem;
    font-family: var(--sans-serif-font);
}
.tr-verdict.yes { background: #2f9e4426; color: #2f9e44; }
.tr-verdict.no { background: #e0313126; color: #e03131; }

.tr-bits {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
}
.tr-bit {
    position: relative;
    overflow: hidden;
    border-radius: 3px;
    padding: 0.15rem 0;
    font-size: 0.75rem;
    font-family: var(--mono-font, monospace);
    text-align: center;
}
.tr-bit.ok { background: #2f9e4426; color: #2f9e44; }
.tr-bit.bad { background: #e0313140; color: #e03131; font-weight: 700; }
/* Share of blocks that voted for the hidden bit: full = unanimous, under half = flipped. */
.tr-bit-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    opacity: 0.7;
    background: currentColor;
    height: 3px;
}

@media (max-width: 720px) {
    .tr-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tr-lab { grid-template-columns: 1fr; }
    .tr-val { min-width: 0; }
}
