/* The piece picker: sight reading's catalog in a dialog, a composer and then
   one of their pieces, with a search over both and a way to open a file from
   the device. Shared by sight reading's Choose a piece and the music stand's
   Open music, each of which styles its buttons as its own; the few the
   picker sets apart are set here over either page's. */

/* A modal over the page: search on top, then the composers — or, once one
   is chosen, a way back and their pieces — scrolling on their own. */
.picker {
  width: min(640px, calc(100vw - 32px));
  max-height: min(720px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.picker[open] {
  display: flex;
  flex-direction: column;
}

/* With a phone's keyboard up, what of the page still shows, set by the script. */
.picker.is-fitted {
  top: var(--shown-top);
  bottom: auto;
  margin-block: 8px 0;
  max-height: calc(var(--shown-height) - 16px);
}

.picker::backdrop {
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px 0;
}

.picker-title {
  margin: 0;
  font-size: 17px;
}

.picker .picker-close {
  min-width: 34px;
  padding: 4px 12px;
  font-size: 18px;
  line-height: 1;
}

/* Its buttons lit as they are hovered, whichever page's they are. */
.picker .picker-close:hover,
.picker .picker-major:hover,
.picker .open-button:hover,
.picker .picker-back:hover {
  border-color: var(--accent);
}

.picker-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 0;
}

.picker-search {
  flex: 1 1 220px;
  min-width: 0;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px; /* under 16px, iOS zooms the page to a field focused */
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.picker .picker-major {
  display: inline-flex;
  flex: none;
  align-items: center;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 400;
}

/* Whole beside the search, or on a line of its own when there is no room. */
.picker .open-button {
  flex: none;
}

.picker-search:focus-visible,
.picker-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.picker-crumb:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px 0;
}

.picker .picker-back {
  padding: 4px 12px;
  font-weight: 400;
}

.picker-composer-name {
  margin: 0;
  font-size: 16px;
}

.picker-count {
  margin: 0;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.picker-results {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 8px 12px;
}

.picker-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.picker-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  width: 100%;
  padding: 8px;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.picker-item:hover,
.picker-item:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.picker-item.is-current {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.picker-item-title {
  font-size: 15px;
}

.picker-item-note {
  font-size: 13px;
  color: var(--muted);
}

/* A saved score carries its way out of the account beside it, and a
   catalog piece its star. */
.picker-list li.has-action {
  display: flex;
  align-items: center;
  gap: 4px;
}

.picker-remove,
.picker-star {
  flex: none;
  padding: 4px 10px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.picker-remove:hover,
.picker-remove:focus-visible,
.picker-star:hover,
.picker-star:focus-visible {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.picker-star[aria-pressed="true"] {
  color: var(--accent);
}

.picker-remove.is-confirming {
  font-size: 13px;
  font-weight: 600;
  color: var(--alert-solid);
}

/* Major composers: lit while the composers are kept to them. */
.picker .picker-major[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.picker .picker-major[aria-pressed="false"] {
  color: var(--muted);
}

/* A link offered is shown whole, broken wherever it must be to fit. */
.picker-item[data-url] .picker-item-note {
  overflow-wrap: anywhere;
}
