/* Director answer key (#key). Cards follow the Program Partner tokens on
   screen and switch to plain black-on-white for printing. */

.key-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.key-legend li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.key-tag {
  display: inline-block;
  justify-self: start;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  padding: 0 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.key-tag.primary {
  background: var(--primary);
  color: var(--primary-foreground);
}

.key-tag.same {
  background: color-mix(in srgb, var(--success) 16%, var(--card));
  color: var(--success);
}

.key-tag.alt {
  background: color-mix(in srgb, var(--warning) 20%, var(--card));
  color: var(--foreground);
}

.key-tag.wrong {
  background: color-mix(in srgb, var(--destructive) 12%, var(--card));
  color: var(--destructive);
}

.key-controls {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.key-controls .key-include {
  grid-column: 1 / -1;
}

.key-sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
}

.key-sheet-head h2 {
  margin: 0;
}

.key-inst-note {
  margin: 0.25rem 0 1rem;
}

.key-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
}

.key-grid.text {
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
}

.key-note {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  break-inside: avoid;
}

.key-note-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.key-note h3 {
  font-size: 1rem;
  margin: 0;
}

.key-staff {
  width: 64px;
  height: auto;
  flex: none;
}

.key-fingering {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.key-fingering figcaption {
  font-weight: 600;
  text-align: center;
}

.key-fingering.alt figcaption {
  font-weight: 500;
  font-size: 0.75rem;
}

.key-diagram svg {
  display: block;
}

.key-fingering .diagram {
  width: auto;
  height: 220px;
  max-width: 100%;
}

.key-fingering.alt .diagram {
  height: 132px;
}

.key-fingering .diagram-valves {
  width: 132px;
  height: auto;
}

.key-fingering.alt .diagram-valves {
  width: 96px;
  height: auto;
}

.key-also {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
  font-size: 0.8125rem;
}

.key-alts {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.key-alt-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem 0.75rem;
}

@media (max-width: 560px) {
  .key-legend li {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .key-grid,
  .key-grid.text {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.5rem;
  }

  .key-fingering .diagram {
    height: 150px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print {
    display: none !important;
  }

  .app {
    max-width: none;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: none;
    padding: 0;
  }

  /* Paper is white whatever the screen theme is. */
  .key-sheet {
    --foreground: #000;
    --card: #fff;
    --card-foreground: #000;
    --border: #999;
    --muted-foreground: #444;
    --primary: #000;
    --primary-foreground: #fff;
    --success: #1f6b3a;
    --warning: #8a6100;
    color: #000;
    background: #fff;
  }

  .key-grid,
  .key-grid.text {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
  }

  .key-note {
    padding: 0.4rem;
  }

  .key-fingering .diagram {
    height: 150px;
  }

  .key-fingering.alt .diagram {
    height: 90px;
  }
}
