/* NEW: Key Signature Layout */
#superstaff-layout {
  position: relative;
  width: 300px;
  margin: 20px auto;
  height: 350px;
  opacity: 1;
  transform: translateY(0) scale(1);
  /* Smooth transition for layout expansion and fade */
  transition: height 0.6s cubic-bezier(0.25, 1, 0.5, 1),
              margin 0.6s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 0.4s ease 0.1s,
              transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

#superstaff-layout.hidden {
  height: 0px;
  margin: 0px auto;
  opacity: 0;
  transform: translateY(15px) scale(0.98);
  pointer-events: none;
  /* Snappier fade out, same smooth collapse */
  transition: height 0.6s cubic-bezier(0.25, 1, 0.5, 1),
              margin 0.6s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 0.25s ease,
              transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

#key-sig-controls {
  position: absolute;
  left: -50px; 
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

#key-sig-controls button {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0px 10px; 
  margin: 0;
  transition: all 0.2s ease, color 0.6s ease;
}

#key-sig-controls button:hover {
  color: #fff;
  transform: scale(1.1);
}

#key-display {
  font-family: 'Alumni Sans Pinstripe', sans-serif;
  font-size: 2rem;
  font-weight: bold;
  color: #fff;
  margin: 0;
  width: 40px;
  height: 60px; 
  position: relative;
  overflow: hidden;
  transition: color 0.6s ease;
}

/* Animation wrapper for the key text */
.key-text-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
}

.key-text-wrapper.out-up {
  transform: translateY(-100%);
  opacity: 0;
}

.key-text-wrapper.out-down {
  transform: translateY(100%);
  opacity: 0;
}

.key-text-wrapper.in-from-bottom {
  transform: translateY(100%);
  opacity: 0;
}

.key-text-wrapper.in-from-top {
  transform: translateY(-100%);
  opacity: 0;
}

.key-text-wrapper.active {
  transform: translateY(0);
  opacity: 1;
}

.key-accidental {
  font-family: sans-serif;
  font-size: 0.6em;
  margin-left: -4px;
  vertical-align: 15%;
  font-weight: normal;
}

/* Existing Staff CSS */
#superstaff-container {
  width: 300px;
  margin: 0;
}

#superstaff-svg {
  width: 300px;
  height: 350px;
  display: block;
  background: transparent;
}

/* All staff lines exactly 1px */
.superstaff-line {
  stroke-width: 1;
  stroke: #ffffff;
  transition: stroke 0.6s ease;
}

.superstaff-line.black-line {
  stroke-width: 1;
  stroke: transparent;
}

/* Whole note PNG: exactly 12px tall (distance between 3 staff lines) */
.whole-note-image {
  width: 21px;
  height: 12px;
  pointer-events: none;
  image-rendering: auto;
  transform: translate(-10px, -6px);
  transition: filter 0.6s ease;
}

/* Accidentals (#) */
.music-glyph {
  font-family: "Noto Music", sans-serif !important;
  fill: #ffffff;
  font-size: 28px;
  user-select: none;
  dominant-baseline: middle;
  text-anchor: middle;
  transition: fill 0.6s ease;
}

/* Clefs */
.clef-glyph {
  font-family: "Noto Music", sans-serif !important;
  fill: #ffffff;
  font-size: 48px;
  user-select: none;
  dominant-baseline: middle;
  text-anchor: middle;
  transition: fill 0.6s ease;
}

/* === Day Mode Notation Overrides === */
body.day-mode #key-display {
  color: #000000;
}

body.day-mode #key-sig-controls button {
  color: #666;
}

body.day-mode #key-sig-controls button:hover {
  color: #000;
}

body.day-mode .superstaff-line {
  stroke: #000000;
}

/* Prevent the Day Mode override from revealing the hidden staff lines */
body.day-mode .superstaff-line.black-line {
  stroke: transparent;
}

body.day-mode .music-glyph,
body.day-mode .clef-glyph {
  fill: #000000;
}

/* Invert inline strokes for dynamically drawn ledgers */
body.day-mode #superstaff-svg line[stroke="#fff"] {
  stroke: #000000 !important;
}

/* Invert the whole note image */
body.day-mode .whole-note-image {
  filter: invert(1);
}