/* The library as a tesseract: the two lines of navigation, the line of
   instructions along the bottom of the page, the reading line and notes.
   The stage, labels, card and list view come from library.css. */

.library-navs {
  display: flex;
  flex-direction: column;
  gap: calc(var(--line) / 3);
}

/* A quiet, still waveform when muted; moving bars only while music plays. */
.music-toggle {
  opacity: 0.3;
}

.music-toggle.is-playing {
  opacity: 0.75;
}

.music-wave path {
  transform-origin: 50% 50%;
  transform: scaleY(0.3);
}

/* While the music plays, each bar rises and falls on its own: an uneven
   pattern of heights, a little under a second from one to the next, and a
   cycle of a different length for each bar, so they never fall into step
   and the whole never visibly repeats. */
.music-toggle.is-playing .music-wave path {
  animation: 5.3s ease-in-out infinite;
}

.music-toggle.is-playing .music-wave path:nth-child(1) { animation-name: music-wave-1; animation-duration: 4.7s; }
.music-toggle.is-playing .music-wave path:nth-child(2) { animation-name: music-wave-2; animation-duration: 6.1s; animation-delay: -2.3s; }
.music-toggle.is-playing .music-wave path:nth-child(3) { animation-name: music-wave-3; animation-duration: 5.3s; animation-delay: -1.1s; }
.music-toggle.is-playing .music-wave path:nth-child(4) { animation-name: music-wave-2; animation-duration: 6.7s; animation-delay: -4.6s; }
.music-toggle.is-playing .music-wave path:nth-child(5) { animation-name: music-wave-1; animation-duration: 5.9s; animation-delay: -3.2s; }

@keyframes music-wave-1 {
  0%, 100% { transform: scaleY(0.35); }
  13% { transform: scaleY(0.8); }
  27% { transform: scaleY(0.5); }
  38% { transform: scaleY(0.62); }
  55% { transform: scaleY(0.28); }
  71% { transform: scaleY(0.95); }
  86% { transform: scaleY(0.55); }
}

@keyframes music-wave-2 {
  0%, 100% { transform: scaleY(0.6); }
  11% { transform: scaleY(0.3); }
  29% { transform: scaleY(1); }
  42% { transform: scaleY(0.7); }
  57% { transform: scaleY(0.82); }
  74% { transform: scaleY(0.38); }
  88% { transform: scaleY(0.66); }
}

@keyframes music-wave-3 {
  0%, 100% { transform: scaleY(0.75); }
  16% { transform: scaleY(0.45); }
  30% { transform: scaleY(0.9); }
  47% { transform: scaleY(0.33); }
  61% { transform: scaleY(0.58); }
  78% { transform: scaleY(1); }
  91% { transform: scaleY(0.5); }
}

@media (prefers-reduced-motion: reduce) {
  .music-toggle.is-playing .music-wave path {
    animation: none;
    transform: none;
  }
}

/* The bookcases of the collection you are in, under the collections. */
.wall-nav {
  font-size: 0.875rem;
  opacity: 0.8;
}

.wall-nav .count {
  font-size: 0.8125rem;
}

/* List view: a genre inside a collection. */
.book-list .group-name {
  margin: calc(var(--line) * 1.5) 0 calc(var(--line) / 2);
  font-family: var(--font-caps);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: lowercase;
}

.book-list h2 + .group-name {
  margin-top: 0;
}

.book-card-title.is-quote {
  font-size: 1.25rem;
  line-height: calc(var(--line) * 1.25);
}

/* The line of instructions, at the foot of the page. */
:root[data-view="library"] .library-hint {
  bottom: calc(var(--line) * 0.75);
}

/* A shade along the bottom, behind the instructions and the reading line. */
.library-scrim.is-bottom {
  inset: auto 0 0;
  height: 6.5rem;
  background: linear-gradient(
    to top,
    var(--background) 0,
    color-mix(in srgb, var(--background) 85%, transparent) 45%,
    transparent 100%
  );
}

@media (max-width: 720px) {
  .book-card {
    bottom: 0;
    z-index: 4;
  }
}

/* The reading line: the title under the pointer, set in the page's own type,
   with its neighbours on the shelf fading out on either side. */
.reading-line {
  display: none;
}

:root[data-view="library"] .reading-line {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--line) * 2.5);
  z-index: 2;
  display: block;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
}

:root[data-view="library"] .reading-line.is-visible {
  opacity: 1;
}

.reading-track {
  position: relative;
  left: 50%;
  display: flex;
  width: max-content;
  gap: 3.2ch;
  font-size: 1.125rem;
  font-style: italic;
  white-space: nowrap;
  transition: transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.reading-item {
  transition: opacity 420ms ease;
}

.reading-item.is-roman {
  font-style: normal;
}

.reading-meta {
  margin: calc(var(--line) / 6) 0 0;
  font-size: 0.875rem;
  text-align: center;
  opacity: 0.6;
}

.reading-meta .who {
  font-family: var(--font-caps);
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

@media (prefers-reduced-motion: reduce) {
  .reading-track,
  .reading-item {
    transition: none;
  }
}

/* Notes: on the card, and under a work in the list. */
.book-card-note:empty {
  display: none;
}

.book-card-note {
  margin-top: var(--line);
  padding-top: calc(var(--line) / 2);
  border-top: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
}

.book-card-note .note-label {
  margin: 0 0 calc(var(--line) / 4);
  font-family: var(--font-caps);
  font-size: 0.8125rem;
  letter-spacing: 0.075em;
  text-transform: lowercase;
  opacity: 0.6;
}

.book-card-note .note-text p,
.list-note p,
.vol-note p,
.contents li.note-row p {
  margin: 0 0 calc(var(--line) / 3);
}

.book-card-note .note-text {
  font-size: 0.9375rem;
}

.note-input {
  box-sizing: border-box;
  width: 100%;
  padding: 0.35rem 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 30%, transparent);
  background: none;
  color: inherit;
  font: italic 0.9375rem/1.5 var(--font-text);
  resize: vertical;
}

.note-input:focus {
  outline: none;
  border-bottom-color: var(--text);
}

.note-tools {
  margin: calc(var(--line) / 4) 0 0;
  font-size: 0.8125rem;
  font-style: italic;
  opacity: 0.6;
}

.note-tools button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.contents li.note-row,
.list-note,
.vol-note {
  display: block;
  margin: 0 0 calc(var(--line) / 3) 2ch;
  font-size: 0.875rem;
  font-style: italic;
  opacity: 0.7;
}

.contents li.note-row::before {
  content: none;
}
