/* Sega Rally 2006 per-channel player. Restyle through the custom properties. */
.sr2006 {
  --sr2006-bg: #0d1014;
  --sr2006-panel: #151a21;
  --sr2006-border: #232b35;
  --sr2006-text: #e8edf2;
  --sr2006-muted: #8a96a3;
  --sr2006-accent: #ffb020;
  --sr2006-line: #7cf3c4;
  --sr2006-mix-line: #ffffff;
  --sr2006-dim: rgba(255, 255, 255, 0.14);
  --sr2006-cols: 3;
  background: var(--sr2006-bg);
  color: var(--sr2006-text);
  border: 1px solid var(--sr2006-border);
  border-radius: 12px;
  padding: 16px;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.sr2006 button { font: inherit; color: inherit; }
/* minmax(0, 1fr) and min-width: 0: a long track title is cut off with an
   ellipsis instead of pushing the player wider than the screen. */
.sr2006-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.sr2006-main > * { min-width: 0; }
.sr2006-head { display: flex; align-items: center; gap: 12px; }
.sr2006-play {
  min-width: 72px; height: 40px; border-radius: 20px; cursor: pointer;
  background: var(--sr2006-accent); color: #111; border: 0; font-weight: 600;
}
.sr2006-titlebox { flex: 1; min-width: 0; }
.sr2006-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr2006-status { color: var(--sr2006-muted); font-size: 12px; }
.sr2006-time { font-variant-numeric: tabular-nums; color: var(--sr2006-muted); white-space: nowrap; }
.sr2006-bar {
  position: relative; height: 8px; border-radius: 4px; cursor: pointer;
  background: var(--sr2006-panel); border: 1px solid var(--sr2006-border);
}
/* The bar is thin; this makes it easier to hit with a finger. */
.sr2006-bar::before { content: ""; position: absolute; inset: -10px 0; }
.sr2006-bar-loop {
  position: absolute; top: 0; bottom: 0; border-radius: 4px;
  background: color-mix(in srgb, var(--sr2006-line) 30%, transparent);
}
.sr2006-bar-pos {
  position: absolute; top: -3px; width: 2px; height: 12px; margin-left: -1px;
  background: var(--sr2006-accent);
}
/* A scope has the height; its canvas fills it. The canvas stays out of the
   layout, so the size it is drawn at can never push the box larger. */
.sr2006-scope {
  position: relative; height: 84px;
  /* The thin centre line is part of the background, so the script does not
     have to draw it again in every frame. It is one screen pixel thin: the
     script sets --sr2006-hair to that size for the screen at hand. */
  background: linear-gradient(var(--sr2006-dim), var(--sr2006-dim)) 0 50% / 100% var(--sr2006-hair, 1px) no-repeat, var(--sr2006-panel);
  border: 1px solid var(--sr2006-border); border-radius: 8px; overflow: hidden;
}
.sr2006-scope canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.sr2006-scope-mix { height: 120px; }
.sr2006-label {
  position: absolute; top: 6px; left: 8px; font-size: 11px; letter-spacing: 0.06em;
  color: var(--sr2006-muted); pointer-events: none;
}
/* --sr2006-cols scopes to a row (set by the script for the number of
   channels). A last row that is not full stretches to the full width. */
.sr2006-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.sr2006-grid .sr2006-scope {
  flex: 1 1 calc((100% - (var(--sr2006-cols) - 1) * 8px) / var(--sr2006-cols) - 0.5px);
  min-width: 0;
}
.sr2006-tracks { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.sr2006-track {
  display: flex; gap: 8px; align-items: baseline; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid var(--sr2006-border); border-radius: 8px; padding: 8px 10px;
}
.sr2006-track:hover { border-color: var(--sr2006-muted); }
.sr2006-track.is-current { border-color: var(--sr2006-accent); }
.sr2006-track-n { color: var(--sr2006-muted); font-variant-numeric: tabular-nums; }
.sr2006-track-t { flex: 1; }
.sr2006-track-c { color: var(--sr2006-muted); font-size: 12px; }
@media (max-width: 560px) {
  .sr2006 { padding: 12px; }
  .sr2006-grid .sr2006-scope { flex-basis: calc(50% - 4.5px); height: 64px; }
  /* Phone: the title gets the full width beside the button and may take two
     lines; the time moves down next to the status. */
  .sr2006-head {
    display: grid; align-items: center; gap: 2px 12px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "play title title" "play status time";
  }
  .sr2006-play { grid-area: play; }
  .sr2006-titlebox { display: contents; }
  .sr2006-title { grid-area: title; align-self: end; white-space: normal; }
  .sr2006-status { grid-area: status; align-self: start; }
  .sr2006-time { grid-area: time; align-self: start; font-size: 12px; }
}

/* Wide screens: the track list stands beside the scopes, and the player has
   a fixed height (--sr2006-height) that the scopes share out: the mix gets a
   little more than a row of channels. Everything is in view at once. */
@media (min-width: 1000px) {
  .sr2006 {
    grid-template-columns: minmax(0, 1fr) max-content;
    column-gap: 16px;
    height: var(--sr2006-height, 30rem);
  }
  .sr2006-main { display: flex; flex-direction: column; min-height: 0; }
  .sr2006-head, .sr2006-bar { flex: none; }
  .sr2006-scope-mix { flex: 1.4 1 0; height: auto; min-height: 56px; }
  .sr2006-grid { flex: var(--sr2006-rows, 2) 1 0; min-height: calc(var(--sr2006-rows, 2) * 52px); }
  .sr2006-grid .sr2006-scope { height: auto; }
  .sr2006-tracks { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
  /* The tracks share the height of the list between them, so the whole list
     is in view; only on a very low screen does it scroll. */
  .sr2006-track { flex: 1 1 0; min-height: 26px; padding-top: 0; padding-bottom: 0; align-items: center; white-space: nowrap; }
}
