/* ============================================================================
   widgets/rnaq.css  --  the RNA quantification widgets (static/js/rnaq/).

   Loaded by reference/rna-quantification/_metadata.yml and by the Lecture 2.3
   page. Owned by the widget author. Class prefix .rq-.

   Every color comes from base/tokens.css (--viz-*, --course-*), so the widgets
   follow the light/dark toggle (body.quarto-dark) with no rule of their own.
   Chart colors are set on SVG through `style` attributes in the JS.
   The partials in reference/rna-quantification/_widgets/ wrap each widget in
   `.rq-box`, with a `.try` prompt and an `.rq-src` note.
   ==========================================================================*/

.rq-box {
    border: 1px solid var(--course-rule);
    border-radius: var(--course-radius, 6px);
    padding: 0.6rem 0.9rem 0.3rem;
    margin: 1.2rem 0;
}

.rq-box>p:first-child {
    margin-top: 0.2rem;
}

.rq-box .try {
    border-left: 4px solid var(--viz-1);
    background: color-mix(in srgb, var(--viz-1) 8%, var(--course-paper));
    padding: 0.4rem 0.8rem;
    margin: 0.8rem 0;
    border-radius: 3px;
}

.rq-box .rq-src,
.rq-src {
    font-size: 0.8rem;
    color: var(--course-muted);
    margin: 0.2rem 0 0.4rem;
}

/* ---------------------------------------------------------------- widget */

.rq {
    color: var(--course-ink);
    font-size: 0.93rem;
    line-height: 1.45;
    max-width: 100%;
    min-width: 0;
}

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

.rq-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    align-items: flex-start;
    margin: 0.3rem 0 0.4rem;
}

.rq-control {
    min-width: 0;
}

.rq fieldset.rq-radios {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.rq fieldset.rq-radios legend {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 0.1rem;
    padding: 0;
    float: none;
    width: auto;
    line-height: 1.3;
}

.rq label.rq-radio {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.05rem 0;
    cursor: pointer;
}

.rq fieldset.rq-inline label.rq-radio {
    display: inline-flex;
    margin-right: 1rem;
}

.rq input[type="radio"],
.rq input[type="checkbox"] {
    accent-color: var(--viz-1);
    margin: 0;
    flex: none;
    width: 1rem;
    height: 1rem;
}

.rq-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.rq-check label {
    cursor: pointer;
}

.rq-slider {
    flex: 1 1 15rem;
    max-width: 22rem;
}

.rq-slider label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
}

.rq-slider-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rq-slider input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: var(--viz-1);
}

.rq-out {
    font-variant-numeric: tabular-nums;
    min-width: 3.5em;
    text-align: left;
    font-weight: 600;
}

.rq-hint {
    font-size: 0.78rem;
    color: var(--course-muted);
}

.rq-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.4rem 0;
    align-items: center;
}

.rq-btn {
    font: inherit;
    font-size: 0.85rem;
    color: var(--course-ink);
    background: var(--course-wash);
    border: 1px solid var(--course-rule);
    border-radius: 4px;
    padding: 0.2rem 0.65rem;
    cursor: pointer;
    min-height: 2rem;
}

.rq-btn:hover:not(:disabled) {
    border-color: var(--course-muted);
}

.rq-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.rq-btn[aria-pressed="true"] {
    background: color-mix(in srgb, var(--viz-1) 18%, var(--course-paper));
    border-color: var(--viz-1);
    font-weight: 600;
}

.rq-btn:focus-visible,
.rq input:focus-visible,
.rq-scroll:focus-visible {
    outline: 2px solid var(--viz-1);
    outline-offset: 2px;
}

.rq-readout {
    margin: 0.4rem 0;
    font-size: 0.9rem;
}

.rq-readout b,
.rq-detail b {
    font-variant-numeric: tabular-nums;
}

.rq-detail {
    margin: 0.3rem 0 0.6rem;
    padding: 0.4rem 0.7rem;
    background: var(--course-wash);
    border-radius: 4px;
    font-size: 0.88rem;
    min-height: 2.6em;
}

.rq-figure {
    margin: 0.4rem 0;
    max-width: 100%;
    overflow: hidden;
}

.rq-svg {
    display: block;
    max-width: 100%;
    height: auto;
    font-family: inherit;
}

.rq-svg text {
    font-family: inherit;
}

.rq-panel-title {
    font-weight: 600;
    font-size: 0.92rem;
    margin: 0.8rem 0 0.1rem;
}

.rq-sub {
    font-size: 0.82rem;
    color: var(--course-muted);
    margin: 0 0 0.3rem;
}

/* ---------------------------------------------------------------- tables */

.rq-scroll {
    overflow-x: auto;
    max-width: 100%;
    margin: 0.3rem 0 0.7rem;
}

.rq-table {
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
    border-collapse: collapse;
    margin: 0;
}

.rq-table caption {
    caption-side: top;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--course-ink);
    padding: 0 0 0.2rem;
}

.rq-table th,
.rq-table td {
    padding: 2px 8px;
    text-align: right;
    border-bottom: 1px solid var(--course-rule);
    vertical-align: top;
}

.rq-table thead th {
    font-weight: 600;
    border-bottom-width: 2px;
    white-space: nowrap;
}

.rq-table thead th:first-child,
.rq-table thead th.rq-left {
    text-align: left;
}

.rq-table.rq-wrap-head thead th {
    white-space: normal;
    vertical-align: bottom;
}

.rq-table tbody th,
.rq-table tfoot th {
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.rq-table tfoot th,
.rq-table tfoot td {
    border-top: 2px solid var(--course-rule);
    font-weight: 600;
}

.rq-table tr.rq-sel th,
.rq-table tr.rq-sel td {
    background: color-mix(in srgb, var(--viz-5) 20%, var(--course-paper));
}

.rq-table tr.rq-later th,
.rq-table tr.rq-later td {
    color: var(--course-muted);
}

.rq-table .rq-left {
    text-align: left;
}

.rq-table .rq-hl {
    font-weight: 700;
    background: color-mix(in srgb, var(--viz-1) 12%, var(--course-paper));
}

.rq-table .rq-nowrap {
    white-space: nowrap;
}

.rq-table .rq-muted {
    color: var(--course-muted);
}

/* the counting widget's per-read table reads as text */
.rq-reads .rq-table td,
.rq-reads .rq-table thead th {
    text-align: left;
}

.rq-reads .rq-table td:last-child {
    white-space: nowrap;
}

.rq-reads .rq-table td:nth-child(2) {
    min-width: 12rem;
}

.rq-reads .rq-table td:nth-child(3) {
    min-width: 9rem;
}

/* a small table beside a text box; stacks on a phone */
.rq-pair {
    display: flex;
    flex-wrap: wrap;
    gap: 0 1.2rem;
    align-items: flex-start;
}

.rq-pair>.rq-detail,
.rq-pair>.rq-grow {
    flex: 1 1 16rem;
}

/* labels printed on a colored bar: white on --viz-1 in light mode, black on the lighter dark-mode palette */
.rq-svg text.rq-on-strong {
    fill: #fff;
}

.rq-svg text.rq-on-light,
body.quarto-dark .rq-svg text.rq-on-strong {
    fill: #000;
}

/* the length widget: one small fieldset of sliders per gene */
.rq-gene-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 0.6rem;
    margin: 0.3rem 0 0.5rem;
}

.rq fieldset.rq-gene {
    border: 1px solid var(--course-rule);
    border-radius: 4px;
    padding: 0.2rem 0.6rem 0.3rem;
    margin: 0;
    min-width: 0;
}

.rq fieldset.rq-gene legend {
    font-weight: 700;
    font-size: 0.88rem;
    float: none;
    width: auto;
    padding: 0 0.3rem;
    margin: 0;
}

.rq-gene .rq-slider {
    max-width: none;
}

.rq-gene .rq-slider label {
    font-weight: 400;
    font-size: 0.8rem;
}

/* a key: swatch + label, so color never carries meaning alone */
.rq-key {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
    font-size: 0.82rem;
    margin: 0.2rem 0;
}

.rq-key span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.rq-sw {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border-radius: 2px;
    flex: none;
}

.rq-note-ok {
    color: var(--course-practice);
    font-weight: 600;
}

.rq-note-bad {
    color: var(--course-caution);
    font-weight: 600;
}

@media (max-width: 560px) {
    .rq-box {
        padding: 0.5rem 0.5rem 0.2rem;
    }

    .rq-controls {
        gap: 0.5rem 0.9rem;
    }

    .rq-slider {
        flex-basis: 100%;
        max-width: none;
    }

    .rq-table {
        font-size: 0.8rem;
    }

    .rq-table th,
    .rq-table td {
        padding: 2px 5px;
    }
}
