/* room_add -- the "Add a song" screen. Tokens only; see design_tokens.yml.
 *
 * Structure only, like every stylesheet outside skins/: no literal colour,
 * no [data-skin], no var() fallback. Sizes the contract has no word for
 * (a 56px thumbnail, a 40px row button) are written as lengths, since a
 * length is not identity; anything that could differ between skins is a
 * token or is derived from one.
 */

.rk-add-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

/* A back button is a thumb target: 44px, a ghost face, and the icon button's
   own inset rim -- the faint square the reference draws -- which the ghost
   primitive otherwise switches off. Scoped under the header so it outranks
   that pair of modifiers; it presses like every other icon button. */
.rk-add-head__back {
  width: var(--space-7);
  height: var(--space-7);
  flex: 0 0 auto;
}

.rk-add-head .rk-add-head__back,
.rk-add-head .rk-add-head__back:hover:not(:disabled):not(:active) {
  box-shadow: var(--control-icon-shadow);
}

.rk-add-head .rk-add-head__back:active { box-shadow: var(--control-icon-shadow-active); }

.rk-add-head__text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.rk-add-head__title { margin: 0; }

.rk-add-head__sub { margin: 0; }

/* ------------------------------------------------------------ search field */

/* The field is the shared component; this is what the add screen hangs on it:
   the glass in the accent, room at the end for the clear control, and the
   browser's own cancel glyph switched off so there is one × rather than two. */
.rk-add-search { position: relative; }

.rk-add-search .rk-search > svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.rk-add-search .rk-search__input { padding-right: var(--space-6); }

.rk-add-search .rk-search__input::-webkit-search-cancel-button,
.rk-add-search .rk-search__input::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.rk-add-search__clear {
  position: absolute;
  top: 50%;
  right: var(--space-1);
  translate: 0 -50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: var(--edge-radius-sm);
  color: var(--ink-muted);
  cursor: pointer;
}

.rk-add-search__clear:hover { color: var(--ink-primary); }

.rk-add-search__clear:focus-visible {
  outline: none;
  box-shadow: var(--focus-shadow);
}

/* Nothing typed, nothing to clear. The placeholder is only shown while the
   field is empty, so it is the field's own word for that. */
.rk-add-search:has(.rk-search__input:placeholder-shown) .rk-add-search__clear { display: none; }

/* -------------------------------------------------------------- the panels */

/* One quiet row: a panel with nothing to list says so in its own body rather
   than above itself. */
.rk-add-empty,
.rk-add-matches .rk-search-empty {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.rk-add-notice {
  margin: 0;
  padding: 0 var(--space-1);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* --------------------------------------------------------------- matches */

/* Between the two type sizes the contract names: what the refusal under a
   row and the line under the paste title are set in. */
.rk-add-matches,
.rk-add-paste {
  --rk-add-text-2xs: calc((var(--text-xs) + var(--text-sm)) / 2);
}

/* A row is three columns -- art, words, one button -- and a hairline above,
   so the first row also draws a line under the title bar. .rk-result gives
   the shared rhythm (history, the shelf); the grid and the top rule are this
   list's own. */
.rk-add-result {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-top: var(--edge-width) solid var(--edge-hairline);
  border-bottom: 0;
}

.rk-add-results .rk-add-result:last-child { border-bottom: 0; }

/* Square art with a corner a step tighter than the small control radius, so a
   skin with square controls gets square art and a rounded one gets a softer
   tile than its buttons. */
.rk-add-result__thumb,
.rk-add-results .rk-result__thumbnail {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: calc(var(--edge-radius-sm) / 1.5);
}

.rk-add-result__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rk-add-result__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-primary);
}

/* The source is the panel's word (its title bar names it); the row keeps its
   own copy for screen readers only, so the meta line stays one line of
   channel, length and plays. */
.rk-add-result__source {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Why this row cannot be added, in the danger ink and allowed to wrap: the
   sentence matters more than the row height here. */
.rk-add-result__refusal {
  font-size: var(--rk-add-text-2xs);
  line-height: 1.35;
  color: var(--danger);
}

/* button_to and form_with wrap the control in a form; the grid has to see the
   button, not the form, so the form dissolves. */
.rk-add-result__form { display: contents; }

/* A row button: shorter and tighter than a standalone control, and the small
   radius, so four of them in a column read as a list rather than as a toolbar.
   Refused, the same button is the default face in the muted ink -- the
   primitive already does that for [disabled]. */
.rk-add-result__button {
  height: 40px;
  padding: 0 var(--space-3);
  gap: var(--space-1);
  border-radius: var(--edge-radius-sm);
  font-size: var(--text-sm);
}

.rk-add-result__alternative {
  max-width: 10rem;
  height: auto;
  min-height: 40px;
  padding-block: var(--space-2);
  white-space: normal;
  text-align: center;
}

/* Several versions of one song sit in a sunken box with a label; the grid
   rows inside it keep the same hairline rhythm. */
.rk-add-matches .rk-result-group__label { padding: var(--space-2) var(--space-3) 0; }

/* ------------------------------------------------------------- paste link */

.rk-add-paste__summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--row-height);
  padding: 10px var(--space-3) 10px 14px;
  list-style: none;
  cursor: pointer;
  color: var(--ink-secondary);
}

.rk-add-paste__summary::-webkit-details-marker { display: none; }

/* The panel clips its corners, so the ring goes inside the row. */
.rk-add-paste__summary:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.rk-add-paste__icon { flex: 0 0 auto; }

.rk-add-paste__text {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.rk-add-paste__title {
  font-family: var(--font-display);
  font-size: var(--control-size);
  color: var(--ink-primary);
}

.rk-add-paste__sub {
  font-size: var(--rk-add-text-2xs);
  color: var(--ink-muted);
}

.rk-add-paste__chevron {
  flex: 0 0 auto;
  color: var(--ink-muted);
  transition: rotate var(--motion-fast) var(--ease);
}

.rk-add-paste[open] .rk-add-paste__chevron { rotate: 90deg; }

.rk-add-paste__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-4) var(--space-4);
}

.rk-add-paste__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

/* ---------------------------------------------------------- yours, waiting */

/* The holding area is a panel of its own wherever it lands: a title bar,
   rows, and a footer with the count and the way to empty it. Rendered inside
   another panel -- under the room's queue -- it gives up its own surface and
   reads as that panel's lower half: one pane, two sections. */
.rk-panel .rk-staged {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.rk-staged__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
}

/* Clock, words, length, remove. The remove column is the button's own width so
   the glyph sits where the queue's own row furniture does. */
.rk-staged__row {
  display: grid;
  grid-template-columns: var(--space-5) minmax(0, 1fr) auto var(--space-7);
  align-items: center;
  gap: var(--space-1) 10px;
  min-height: var(--row-height);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--surface-row);
  color: var(--ink-on-row);
  border-top: var(--edge-width) solid var(--edge-hairline);
}

.rk-staged__row:first-child { border-top: 0; }

/* The secondary accent, because this is not the accent's job: a waiting song
   is neither the one playing nor a thing to press. */
.rk-staged__clock {
  display: flex;
  justify-content: center;
  color: var(--accent-secondary);
}

.rk-staged__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rk-staged__title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--ink-on-row);
}

.rk-staged__when {
  font-size: var(--text-sm);
  color: var(--ink-on-row-dim);
}

.rk-staged__duration {
  font-family: var(--font-readout);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink-on-row-dim);
}

/* button_to wraps its button in a form; without this the grid measures the
   form instead of the control inside it. */
.rk-staged__form { display: contents; }

/* A thumb-sized target in the row's dim ink, answering in --danger only under
   a pointer or a focus ring: a list of waiting songs is not a list of warnings. */
.rk-staged__remove {
  width: var(--space-7);
  height: var(--space-7);
  color: var(--ink-on-row-dim);
}

.rk-staged__remove:hover:not(:active),
.rk-staged__remove:focus-visible { color: var(--danger); }

.rk-staged__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-4);
  border-top: var(--edge-width) solid var(--edge-hairline);
}

.rk-staged__count,
.rk-staged__more {
  font-family: var(--font-label);
  font-size: var(--label-size);
  font-weight: var(--label-weight);
  letter-spacing: var(--label-tracking);
  text-transform: var(--label-transform);
  color: var(--ink-muted);
}

.rk-staged__clear {
  flex: 0 0 auto;
  height: var(--space-7);
  padding-inline: var(--space-3);
  font-size: var(--text-sm);
}

/* Saved songs: keep search and feedback visible while browsing long lists. */
.rk-playlist-browser__scroll {
  max-height: 60vh;
  min-height: 10rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.rk-playlist-browser__scroll .rk-result { align-items: center; }
.rk-playlist-browser__scroll [data-song-title] { overflow-wrap: anywhere; }
.rk-playlist-browser__scroll [data-song-duration] { white-space: nowrap; }

/* Jellyfin is a quiet provenance label, alongside artist and duration. */
.rk-add-result__source--jellyfin {
  margin: 0;
  position: static;
  width: auto;
  height: auto;
  clip: auto;
  clip-path: none;
  overflow: visible;
  white-space: nowrap;
}

/* The library-only toggle heads the matches it narrows. */
.rk-add-scope {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--edge-width) solid var(--edge-hairline);
}

.rk-add-scope__option {
  align-items: center;
  font-size: var(--text-sm);
}

.rk-add-scope__option > input { margin-top: 0; }
