/* The alignment exhibit ("Miss a word. Keep your place."). Built by
   js/alignment-demo.js. Gold is where the tracker has the sheet, in the panel
   beside the controls and on the sheet alike; chord red is the singer. Flat
   fields only, and nothing animates: every state reads as a still. */

.alignment {
  container-type: inline-size;
  display: grid;
  gap: var(--gap);
  min-width: 0;
}

.alignment p,
.alignment ol {
  margin: 0;
}

.alignment :focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.alignment__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.alignment__label {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ink-soft);
}

.alignment__stage {
  display: grid;
  gap: var(--gap);
  min-width: 0;
}

/* The exhibit sits in a column, not the page, so it asks its own width. */
@container (min-width: 44rem) {
  .alignment__stage {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

.alignment__desk {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
}

/* ---------- what was heard, and the line the tracker holds ---------- */

.alignment__now {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--gold);
  color: var(--ink);
}

.alignment__caption {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
}

.alignment__words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  /* room for two rows of words, so a wrap on a phone moves nothing below */
  min-height: 4.25rem;
  align-content: start;
  padding: 0;
  margin-top: 0.25rem;
  list-style: none;
}

.alignment__heard-word {
  padding: 0.15rem 0.6rem;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}

.alignment__heard-word.is-latest {
  font-weight: 700;
  background: var(--ink);
  color: var(--white);
}

.alignment__heard-word--none {
  border-style: dashed;
  color: var(--sm-red);
}

.alignment__heard-word--none.is-latest {
  background: var(--white);
  color: var(--sm-red);
}

.alignment__heard-word--empty {
  background: transparent;
  border-color: transparent;
  padding-inline: 0;
}

.alignment__current {
  /* two lines are reserved: the longest line of the song wraps once */
  min-height: 2.5em;
  margin-top: 0.25rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
}

.alignment__current mark {
  padding: 0 0.2em;
  background: var(--white);
  color: var(--ink);
  border-radius: 0.2em;
}

/* ---------- controls ---------- */

.alignment__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.alignment__button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
}

.alignment__button--primary {
  color: var(--white);
  background: var(--ink);
}

.alignment__button--quiet {
  border-color: var(--ink-soft);
  border-width: 1px;
  font-weight: 400;
}

.alignment__button:hover {
  color: var(--ink);
  background: var(--gold);
}

.alignment__button[aria-disabled="true"],
.alignment__button[aria-disabled="true"]:hover {
  color: var(--ink-soft);
  background: var(--wash);
  border-color: var(--rule);
  cursor: not-allowed;
}

.alignment__status {
  /* the longest sentence, so the page below does not jump while playing */
  min-height: 4.2em;
  font-size: 1rem;
  line-height: 1.4;
  max-width: var(--measure);
}

/* ---------- the sheet ---------- */

.alignment__sheet {
  min-width: 0;
  padding: 1rem 1.25rem 1.25rem;
  background: var(--sm-paper);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.35;
}

.alignment__title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
}

.alignment__section {
  margin-top: 0.7rem;
}

.alignment__section-name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--sm-red);
}

.alignment__row {
  margin-left: -0.75rem;
  padding: 0.15rem 0.5rem;
  border-left: 0.25rem solid transparent;
}

.alignment__row--chords {
  font-weight: 700;
  color: var(--sm-red);
  white-space: pre-wrap;
}

.alignment__row.is-tracked {
  background: var(--gold);
}

.alignment__row.is-sung {
  border-left-color: var(--sm-red);
}

.alignment__word.is-tracked {
  background: var(--white);
  outline: 0.15em solid var(--white);
  border-radius: 0.1em;
}

.alignment__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-top: 1.1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--sand);
  font-size: 0.8125rem;
  line-height: 1.3;
}

.alignment__key {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.alignment__key::before {
  content: "";
  flex: none;
  width: 1rem;
  height: 1rem;
  background: var(--gold);
}

.alignment__key--singer::before {
  width: 0.25rem;
  background: var(--sm-red);
}

/* ---------- inside the algorithm ---------- */

.alignment__inside {
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

.alignment__inside summary {
  min-height: 2.75rem;
  padding: 0.55rem 0;
  font-weight: 700;
  cursor: pointer;
}

.alignment__inside summary:hover {
  background: var(--wash);
}

.alignment__inside-body {
  display: grid;
  gap: 0.6rem;
  padding: 0.25rem 0 1.25rem;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.alignment__inside-body > p,
.alignment__rules {
  max-width: 42rem;
}

.alignment p.alignment__inside-head {
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.alignment__small {
  color: var(--ink-soft);
}

.alignment__guesses {
  display: grid;
  gap: 0.3rem;
  padding: 0;
  list-style: none;
}

.alignment__guess {
  display: grid;
  grid-template-columns: minmax(0, 45%) minmax(0, 1fr) 2.75rem;
  gap: 0.5rem;
  align-items: center;
}

.alignment__guess--empty {
  display: block;
  color: var(--ink-soft);
}

.alignment__track {
  display: block;
  height: 0.75rem;
  background: var(--wash);
}

.alignment__bar {
  display: block;
  height: 100%;
  background: var(--ink);
}

.alignment__guess-weight {
  text-align: right;
}

.alignment__confidence {
  font-weight: 700;
}

.alignment__rules {
  display: grid;
  gap: 0.2rem;
  padding-left: 1.4rem;
  /* the order is the point: the first rule that fits wins */
  list-style: decimal;
}

.alignment__distances {
  width: 100%;
  max-width: 42rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.alignment__distances th,
.alignment__distances td {
  padding: 0.4rem 0.75rem 0.4rem 0;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid var(--rule);
}

.alignment__distances th {
  font-weight: 700;
  border-top: 0;
}

.alignment__note {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.35;
  color: var(--ink-soft);
}
