@layer components {
  :root {
    --player-block-size: 7rem;
  }

  body:has(#player:not([hidden])) main {
    padding-block-end: var(--player-block-size);
  }

  .player:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-raised);
    color: var(--color-foreground);
    border-top: 1px solid var(--color-border);
  }

  .player__toggle,
  .player__skip,
  .player__rate {
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
  }

  .player__toggle,
  .player__skip {
    width: 2.75rem;
  }

  .player__toggle-icon[hidden] {
    display: none;
  }

  .player__body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2xs);
  }

  /* The transport trio sits in the three middle columns, so the play button stays dead center
     whether or not the rate button occupies the last column. */
  .player__controls {
    display: grid;
    grid-template-columns: 1fr auto auto auto 1fr;
    align-items: center;
    gap: var(--spacing-md);
  }

  .player__controls > :nth-child(1) { grid-column: 2; }
  .player__controls > :nth-child(2) { grid-column: 3; }
  .player__controls > :nth-child(3) { grid-column: 4; }

  .player__rate {
    grid-column: 5;
    justify-self: start;
    min-width: 3.25rem;
    margin-inline-start: var(--spacing-xs);
    font-size: var(--font-size-sm);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .player__title {
    font-family: var(--font-serif);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player__time {
    display: flex;
    align-items: center;
    gap: var(--spacing-2xs);
    font-size: var(--font-size-sm);
  }

  .player__progress {
    flex: 1;
    appearance: none;
    background: var(--color-border);
    border-radius: 0;
    height: 2px;
  }

  .player__progress::-webkit-slider-runnable-track {
    background: transparent;
  }

  .player__progress::-webkit-slider-thumb {
    appearance: none;
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--color-signal);
  }

  .player__progress::-moz-range-track {
    background: transparent;
  }

  .player__progress::-moz-range-thumb {
    width: 8px;
    height: 8px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--color-signal);
  }

  .play-button:not(.btn) {
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
  }

  .play-button-icon[hidden] {
    display: none;
  }

  .download-button:not([hidden]) {
    flex: none;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-muted);
    cursor: pointer;
  }

  .download-button-icon[hidden] {
    display: none;
  }
}
