/* The player is drawn in greys like the sequencer: every colour has equal red, green
   and blue (test/grayscale.test.ts refuses any other). A compact, bevelled skin over a
   dark display, after the desktop players of old.

   These styles apply inside the player's shadow root (src/shell.ts), and only there.
   The shell gives the host element `all: initial`, so no property the host page sets
   reaches the player. Custom properties outlast `all`, so the palette is defined on
   the root's top-level elements (.frame, .failure), below the host element, where they
   also set its type and colours. */
.frame,
.failure {
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --bg: #0a0a0a;
  --skin: #1b1b1b;
  --skin-light: #2c2c2c;
  --skin-dark: #0e0e0e;
  --display: #050505;
  --line: #262626;
  --text: #e2e2e2;
  --muted: #8a8a8a;
  --faint: #4a4a4a;
  --bright: #ffffff;
  --lit: #d8d8d8;
  --spectrum-bar: #9a9a9a;
  --spectrum-peak: #f0f0f0;
}

* {
  box-sizing: border-box;
}

.frame,
.failure {
  color-scheme: dark;
  color: var(--text);
  font: 12px / 1.4 var(--mono);
  -webkit-font-smoothing: antialiased;
}

/* The player's viewport: it scrolls a player taller than the host's container, and
   sizes the embedded player, as a frame's window once did. */
.frame {
  container-type: size;
  height: 100%;
  overflow: auto;
  background: var(--bg);
  scrollbar-color: var(--faint) transparent;
}

.frame:focus {
  outline: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 1px solid var(--bright);
  outline-offset: 1px;
}

.app {
  display: grid;
  min-height: 100%;
  padding: 16px;
  place-items: start center;
}

.failure {
  height: 100%;
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--muted);
}

.player {
  width: min(100%, 440px);
  border: 1px solid var(--skin-dark);
  border-radius: 4px;
  background: var(--skin);
  box-shadow:
    inset 1px 1px 0 var(--skin-light),
    inset -1px -1px 0 var(--skin-dark);
}

/* The main window: title bar, display, seek bar, controls. */
.main {
  display: grid;
  gap: 8px;
  padding: 6px 8px 8px;
}

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.bar::before,
.bar::after {
  flex: 1;
  height: 5px;
  border-block: 1px solid var(--faint);
  content: "";
}

.display {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--skin-dark);
  border-radius: 2px;
  background: var(--display);
  box-shadow: inset 1px 1px 0 var(--skin-dark);
}

.readout {
  display: grid;
  gap: 6px;
  width: 112px;
}

.time {
  padding: 0;
  border: 0;
  background: none;
  color: var(--lit);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
  cursor: pointer;
}

[data-state="paused"] .time {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

.spectrum {
  width: 100%;
  height: 32px;
}

.info {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.title {
  overflow: hidden;
  color: var(--lit);
  white-space: nowrap;
}

.title-text {
  display: inline-block;
}

.title.scrolling .title-text {
  padding-left: 100%;
  animation: marquee 14s linear infinite;
}

@keyframes marquee {
  to {
    transform: translateX(-100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .title.scrolling .title-text {
    padding-left: 0;
    animation: none;
  }

  [data-state="paused"] .time {
    animation: none;
  }
}

.details {
  color: var(--muted);
  font-size: 11px;
}

/* Range inputs: a thin groove filled up to the thumb (--fill). */
input[type="range"] {
  height: 14px;
  margin: 0;
  background: none;
  cursor: pointer;
  appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--muted) var(--fill, 0%), var(--skin-dark) 0);
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--muted) var(--fill, 0%), var(--skin-dark) 0);
}

input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border: 1px solid var(--skin-dark);
  border-radius: 2px;
  background: var(--text);
  appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid var(--skin-dark);
  border-radius: 2px;
  background: var(--text);
}

.seek {
  width: 100%;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.transport,
.modes {
  display: flex;
  gap: 2px;
}

.control {
  display: grid;
  width: 30px;
  height: 24px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--skin-dark);
  border-radius: 2px;
  background: var(--skin-light);
  box-shadow: inset 1px 1px 0 var(--faint);
  cursor: pointer;
}

.control svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}

.control:hover {
  color: var(--bright);
}

.control:active,
.control[aria-pressed="true"] {
  background: var(--skin-dark);
  box-shadow: inset 1px 1px 0 var(--bg);
  color: var(--bright);
}

.modes .control {
  width: 26px;
}

.volume {
  flex: 1;
  min-width: 80px;
}

.status:empty {
  display: none;
}

.status {
  color: var(--muted);
}

/* The playlist window. */
.list {
  border-top: 1px solid var(--skin-dark);
  box-shadow: inset 0 1px 0 var(--skin-light);
  padding: 8px;
}

.tracks {
  max-height: min(50cqh, 360px);
  margin: 0;
  padding: 2px 0;
  overflow-y: auto;
  border: 1px solid var(--skin-dark);
  border-radius: 2px;
  background: var(--display);
  list-style: none;
  scrollbar-color: var(--faint) transparent;
}

.track {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr) auto;
  gap: 6px;
  width: 100%;
  padding: 2px 8px;
  border: 0;
  background: none;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.track:hover {
  color: var(--text);
}

.track.current {
  background: var(--skin);
  color: var(--bright);
}

.track-number {
  text-align: right;
}

.track-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-time {
  font-variant-numeric: tabular-nums;
}

.summary {
  display: flex;
  justify-content: space-between;
  padding: 6px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

/* Embedded (mountDnbmPlayer), the player fills its container, the playlist takes the
   height left, and the host names the app. */
[data-embed] .app {
  padding: 0;
  place-items: stretch;
}

[data-embed] .player {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100cqh;
  border: 0;
  border-radius: 0;
}

[data-embed] .bar {
  display: none;
}

[data-embed] .list {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

[data-embed] .tracks {
  flex: 1;
  max-height: none;
}
