/* Ride viewer (js/ride-viewer.js): the run list on the update page and the full-screen viewer. */

.rv-list, .rv {
    --rv-bg: #08090b;
    --rv-panel: #111418;
    --rv-panel-2: #171b21;
    --rv-line: #232931;
    --rv-text: #e8eaed;
    --rv-muted: #8a939e;
    --rv-faint: #5b636d;
    --rv-accent: #ff6b35;
    --rv-good: #34d399;
    --rv-warn: #fbbf24;
    --rv-bad: #f87171;
    font-variant-numeric: tabular-nums;
}

/* ---------- run list ---------- */

.rv-list { display: flex; flex-direction: column; gap: 18px; }
.rv-list-intro { color: var(--rv-muted); font-size: 13px; line-height: 1.55; margin: 0; }
.rv-list-intro code { background: var(--rv-panel-2); color: var(--rv-text); padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.rv-group-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--rv-muted); margin: 0 0 8px; font-weight: 600; }
.rv-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }

.rv-card {
    position: relative; background: linear-gradient(180deg, #121519 0%, #0d0f12 100%);
    border: 1px solid var(--rv-line); border-radius: 12px; padding: 14px 14px 12px;
    display: flex; flex-direction: column; gap: 12px; transition: border-color .15s, transform .15s;
}
.rv-card:hover { border-color: #3a424d; }
.rv-card.is-ready { border-color: rgba(255, 107, 53, .45); }
.rv-card.is-ready::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; border-radius: 12px 0 0 12px; background: var(--rv-accent);
}
.rv-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.rv-card-name { font-size: 15px; font-weight: 650; color: var(--rv-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-card-sub { font-size: 12px; color: var(--rv-faint); white-space: nowrap; }
.rv-card-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rv-mini { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rv-mini b { font-size: 17px; font-weight: 650; color: var(--rv-text); white-space: nowrap; }
.rv-mini span { font-size: 11px; color: var(--rv-muted); }
.rv-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.rv-btn {
    appearance: none; border: 1px solid var(--rv-line); background: var(--rv-panel-2); color: var(--rv-text);
    font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif; padding: 9px 14px; border-radius: 8px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: background .15s, border-color .15s, opacity .15s;
}
.rv-btn:hover { border-color: #3a424d; background: #1d222a; }
.rv-btn:disabled { opacity: .45; cursor: default; }
.rv-btn-primary { background: var(--rv-accent); border-color: var(--rv-accent); color: #160a04; }
.rv-btn-primary:hover { background: #ff7f50; border-color: #ff7f50; }
.rv-btn-ghost { background: transparent; }
.rv-btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }

.rv-progress { display: flex; flex-direction: column; gap: 6px; }
.rv-progress-bar { height: 6px; border-radius: 3px; background: var(--rv-panel-2); overflow: hidden; }
.rv-progress-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff6b35, #ffb020); border-radius: 3px; transition: width .12s linear; }
.rv-progress-text { font-size: 12px; color: var(--rv-muted); display: flex; justify-content: space-between; gap: 8px; }
.rv-card-error { font-size: 12px; color: var(--rv-bad); }
.rv-chip-warn { font-size: 11px; color: var(--rv-warn); }

.rv-empty { border: 1px dashed var(--rv-line); border-radius: 12px; padding: 28px 18px; text-align: center; color: var(--rv-muted); font-size: 14px; }
.rv-empty h3 { color: var(--rv-text); font-size: 16px; margin: 0 0 6px; }

/* ---------- viewer ---------- */

.rv {
    position: fixed; inset: 0; z-index: 2000; background: var(--rv-bg); color: var(--rv-text);
    font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    display: flex; flex-direction: column;
}
.rv[hidden] { display: none; }
.rv-top {
    display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--rv-line);
    background: rgba(8, 9, 11, .92); backdrop-filter: blur(8px); flex: none;
}
.rv-title { min-width: 0; flex: 1; }
.rv-title h2 { margin: 0; font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--rv-text); }
.rv-title p { margin: 2px 0 0; font-size: 12px; color: var(--rv-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.rv-seg { display: inline-flex; border: 1px solid var(--rv-line); border-radius: 8px; overflow: hidden; }
.rv-seg button { appearance: none; border: 0; background: transparent; color: var(--rv-muted); font: 600 12px/1 system-ui, sans-serif; padding: 8px 11px; cursor: pointer; }
.rv-seg button + button { border-left: 1px solid var(--rv-line); }
.rv-seg button.on { background: var(--rv-panel-2); color: var(--rv-text); }
.rv-close { width: 36px; height: 36px; justify-content: center; padding: 0; font-size: 16px; }

.rv-body { flex: 1; overflow-y: auto; overflow-x: hidden; }
.rv-inner { max-width: 1480px; margin: 0 auto; padding: 16px 18px 40px; display: flex; flex-direction: column; gap: 16px; }

.rv-warning { border: 1px solid rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .07); color: #f6d58a; border-radius: 10px; padding: 10px 14px; font-size: 13px; }

.rv-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.rv-tile {
    background: var(--rv-panel); border: 1px solid var(--rv-line); border-radius: 12px; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 3px; position: relative; overflow: hidden;
}
.rv-tile::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--tile, var(--rv-accent)); opacity: .9; }
.rv-tile-label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--rv-muted); font-weight: 600; }
.rv-tile-value { font-size: 24px; font-weight: 750; line-height: 1.1; letter-spacing: -.01em; white-space: nowrap; }
.rv-tile-value small { font-size: 13px; font-weight: 600; color: var(--rv-muted); margin-left: 3px; letter-spacing: 0; }
.rv-tile-sub { font-size: 12px; color: var(--rv-muted); }

.rv-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rv-line); }
.rv-tabs button {
    appearance: none; border: 0; background: transparent; color: var(--rv-muted); padding: 10px 14px; cursor: pointer;
    font: 650 14px/1 system-ui, sans-serif; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.rv-tabs button.on { color: var(--rv-text); border-bottom-color: var(--rv-accent); }
.rv-pane[hidden] { display: none; }
.rv-pane { display: flex; flex-direction: column; gap: 14px; }

.rv-panel { background: var(--rv-panel); border: 1px solid var(--rv-line); border-radius: 12px; padding: 12px 14px 10px; }
.rv-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.rv-panel-title { font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--rv-text); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rv-key { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; color: var(--rv-muted); }
.rv-key i { width: 10px; height: 3px; border-radius: 2px; background: currentColor; display: inline-block; }
.rv-hint { font-size: 12px; color: var(--rv-faint); }

.rv-overview-wrap { position: relative; }
.rv-range { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 13px; color: var(--rv-muted); margin-top: 6px; }
.rv-range b { color: var(--rv-text); font-weight: 650; }

.rv-readout {
    position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 2px 8px;
    background: rgba(17, 20, 24, .94); backdrop-filter: blur(6px); border: 1px solid var(--rv-line); border-radius: 12px; padding: 8px 12px;
}
.rv-read { display: flex; flex-direction: column; min-width: 0; }
.rv-read span { font-size: 11px; color: var(--rv-muted); white-space: nowrap; }
.rv-read b { font-size: 18px; font-weight: 700; white-space: nowrap; }

.rv-play { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rv-play .rv-btn { min-width: 44px; justify-content: center; }

.rv-charts { display: flex; flex-direction: column; gap: 12px; }
.rv-plot { width: 100%; }

.rv-dyno-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; }
.rv-controls { display: flex; flex-direction: column; gap: 14px; }
.rv-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--rv-muted); }
.rv-field-row { display: flex; justify-content: space-between; align-items: baseline; }
.rv-field-row b { color: var(--rv-text); font-size: 15px; }
.rv-field input[type=range] { width: 100%; accent-color: var(--rv-accent); }
.rv-field input[type=number] {
    width: 100%; background: var(--rv-panel-2); border: 1px solid var(--rv-line); color: var(--rv-text);
    border-radius: 8px; padding: 8px 10px; font: 600 14px system-ui, sans-serif;
}
.rv-note { font-size: 12px; color: var(--rv-faint); line-height: 1.5; margin: 0; }
.rv-peaks { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }

.rv-details { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rv-kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.rv-kv dt { color: var(--rv-muted); }
.rv-kv dd { margin: 0; text-align: right; color: var(--rv-text); font-weight: 600; }
.rv pre { background: var(--rv-panel-2); border-radius: 8px; padding: 10px; font-size: 11px; color: var(--rv-muted); max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 0; }

/* uPlot, in the viewer's colours */
.rv .uplot { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.rv .u-select { background: rgba(255, 107, 53, .14); border-left: 1px solid rgba(255, 107, 53, .6); border-right: 1px solid rgba(255, 107, 53, .6); }
.rv .u-cursor-x { border-right: 1px solid rgba(232, 234, 237, .45) !important; }
.rv .u-cursor-y { display: none; }
.rv .u-over { cursor: crosshair; }

@media (max-width: 860px) {
    .rv-dyno-grid { grid-template-columns: 1fr; }
    .rv-top { padding: 10px 12px; flex-wrap: wrap; }
    .rv-inner { padding: 12px 12px 32px; }
    .rv-tile-value { font-size: 22px; }
    .rv-card-stats { grid-template-columns: repeat(2, 1fr); }
    .rv-top-actions .rv-hide-sm { display: none; }
}
