/* styles/poly.css */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.poly__root {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
}

.poly__global {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.poly__boxes {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


.poly-play {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  background: color-mix(in oklab, var(--accent, var(--ink)) 85%, var(--paper) 15%);
  color: var(--paper);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: var(--shadow);
}

.poly-play:active {
  transform: scale(0.96);
}

.poly-play[aria-pressed="true"] {
  background: color-mix(in oklab, var(--accent, var(--ink)) 65%, var(--paper) 35%);
}

.poly-play__icon {
  font-size: 1.2rem;
  line-height: 1;
}

.poly-play__label {
  font-size: 0.95rem;
}

.poly__addBtn {
  width: 56px;
  height: 56px;
  align-self: center;
  border: none;
  border-radius: 18px;
  background: color-mix(in oklab, var(--accent, var(--ink)) 80%, var(--paper) 20%);
  color: var(--paper);
  font-size: 32px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.poly__addBtn:active {
  transform: scale(0.95);
}

.poly__addBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.poly-box {
  background: color-mix(in oklab, var(--paper) 92%, var(--muted) 8%);
  border: 1px solid color-mix(in oklab, var(--muted) 55%, transparent);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow);
}

.poly-box__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.poly-box__titles {
  display: flex;
  align-items: center;
  gap: 16px;
}

.poly-box__top .poly-box__title {
  flex: 1;
}

.poly-box__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.poly-box__actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.poly-box__actions .poly-box__toggle {
  position: static !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  padding: 6px;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--muted) 65%, transparent);
  background: var(--paper);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.poly-box__actions .poly-box__toggle:active {
  transform: scale(0.92) !important;
}

.poly-box__actions .poly-box__toggle .toggle-icon {
  width: 20px;
  height: 20px;
}

.poly-box__actions .poly-box__toggle:hover,
.poly-box__actions .poly-box__toggle:focus-visible {
  background: var(--paper);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent, var(--ink)) 18%, transparent);
}

.poly-box__remove {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid color-mix(in oklab, var(--muted) 65%, transparent);
  background: var(--paper);
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.poly-box__remove:active {
  transform: scale(0.9);
}

.poly-box__remove:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}


.poly-box__toggle {
  align-self: flex-end;
}

.poly-box.poly-display {
  gap: 18px;
}

.poly-box.poly-display .scorebox__row {
  grid-template-columns: 1fr;
}

.poly-box__display {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid color-mix(in oklab, var(--muted) 55%, transparent);
  background: color-mix(in oklab, var(--paper) 96%, var(--muted) 4%);
  font-family: var(--score-font, 'Bravura Text', 'Bravura', 'Noto Music', serif);
  text-align: center;
  direction: ltr;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  box-sizing: border-box;
  overflow: hidden;
}

.poly-display__staff {
  display: block;
  inline-size: 100%;
  max-inline-size: 100%;
  min-inline-size: 0;
  padding-block: 12px 6px;
  font-size: clamp(1.8rem, 2.4vw, 2.8rem);
  line-height: 1;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
}

.poly-display__notes {
  --notes-track-width: 0px;
  position: relative;
  display: block;
  inline-size: max(100%, var(--notes-track-width));
  margin-inline: 0;
  margin-inline: auto;
  padding-block-end: 6px;
  border-bottom: 3px solid #000;
  box-sizing: border-box;
  min-block-size: 3.2em;
}

.poly-display__note {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  line-height: 1;
  font-family: 'Noto Music', 'Bravura Text', 'Bravura', 'FreeSerif', 'Times New Roman', serif;
  white-space: nowrap;
}

.poly-display__meter {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 700;
  font-size: clamp(1rem, 1.2vw, 1.2rem);
  font-family: 'Vazirmatn', 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
}

.poly-display__divider {
  font-size: 0.9em;
}

.poly-display__divider,
.poly-display__slash {
  opacity: 0.65;
}

.poly-box__controls {
  display: grid;
  gap: 16px;
}

.poly-box--collapsed .poly-box__controls {
  display: none;
}

.poly-box--expanded .poly-box__controls {
  display: grid;
}

.poly-controls__mode {
  display: flex;
  justify-content: flex-start;
}


.poly-controls__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.poly-controls__note {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.poly-controls__speed {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 10px;
}

.poly-controls__placeholder {
  min-height: 1px;
}

@media (min-width: 960px) {
  .poly-box__controls {
    grid-template-columns: minmax(0, 1fr);
  }
}

.poly-mode {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-weight: 600;
}

.poly-mode__status {
  min-width: 72px;
}

.poly-toggle {
  position: relative;
  width: 56px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.poly-toggle__input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
}

.poly-toggle__track {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in oklab, var(--muted) 70%, var(--paper) 30%);
  transition: background 0.22s ease;
}

.poly-toggle__track::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  transform: translate(0, -50%);
  transition: transform 0.22s ease;
}

.poly-toggle__input:checked + .poly-toggle__track {
  background: color-mix(in oklab, var(--accent, var(--ink)) 65%, var(--paper) 35%);
}

.poly-toggle__input:checked + .poly-toggle__track::after {
  transform: translate(24px, -50%);
}

.poly-toggle__input:focus-visible + .poly-toggle__track {
  outline: 2px solid color-mix(in oklab, var(--accent, var(--ink)) 65%, transparent);
  outline-offset: 3px;
}

.poly-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poly-field--inline {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.poly-field--inline .poly-field__label {
  white-space: nowrap;
}

.poly-field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.poly-field__label {
  font-weight: 600;
  font-size: 0.95rem;
}

.poly-field__badge {
  font-weight: 600;
  font-size: 0.75rem;
  color: #d32f2f;
  margin-inline-start: 0.5rem;
}

.poly-field__badge[hidden] {
  display: none !important;
}

.poly-note-select {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.poly-note-select__field {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.poly-note-select__field .poly-select--note {
  width: auto;
  inline-size: clamp(3.6rem, 5vw, 4.8rem);
  min-inline-size: 3.4rem;
  padding-inline: 0.6rem;
  text-align: center;
}

.poly-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.poly-input,
.poly-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--muted) 60%, transparent);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.poly-input:focus,
.poly-select:focus {
  border-color: color-mix(in oklab, var(--accent, var(--ink)) 65%, transparent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent, var(--ink)) 25%, transparent);
  outline: none;
}

.poly-range {
  width: 100%;
}

.poly-range::-webkit-slider-thumb {
  cursor: pointer;
}

.poly-range::-moz-range-thumb {
  cursor: pointer;
}

.poly-range__value {
  font-weight: 600;
}

@media (min-width: 640px) {

  .poly-play__label {
    font-size: 1rem;
  }

  .poly-box {
    padding: 22px;
  }
}

@media (max-width: 540px) {
  
  .poly-box__titles {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .poly-box__display {
    width: 100%;
    justify-content: center;
  }
  .poly-display__staff {
    scrollbar-width: none;
  }

  .poly-display__staff::-webkit-scrollbar {
    display: none;
  }
}

.poly-controls__grid > * {
  align-self: stretch;
}

.poly-controls__grid > .poly-field,
.poly-controls__grid > .poly-controls__note,
.poly-controls__grid > .poly-controls__speed,
.poly-controls__grid > .poly-controls__placeholder {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.poly-controls__grid > .poly-controls__speed {
  inline-size: 100%;
}

.poly-controls__grid > .poly-controls__speed .poly-field {
  inline-size: 100%;
}

.poly-controls__speed .poly-field {
  height: 100%;
}

.poly-controls__grid .poly-note-select__field {
  display: flex;
  width: 100%;
  justify-content: center;
}

.poly-controls__grid .poly-note-select__field .poly-select--note {
  width: 100%;
  inline-size: 100%;
  min-inline-size: 0;
  padding-inline: 12px;
}

.poly-controls__note .poly-note-select__field {
  width: 100%;
  justify-content: center;
}

.poly-controls__speed .poly-field {
  flex: 1;
}

/* ==== poly-global simple layout START ==== */
.poly-global__group {
  --poly-fraction-width: clamp(4.3rem, 17vw, 5.2rem);
  display: inline-grid;
  grid-template-columns: var(--poly-fraction-width) minmax(4.5rem, auto) minmax(calc(6ch + 2.2rem), auto);
  grid-auto-flow: row dense;
  column-gap: 1px;
  row-gap: 12px;
  padding: 14px;
  border: 1px solid color-mix(in oklab, var(--muted) 55%, transparent);
  border-radius: 16px;
  background: color-mix(in oklab, var(--paper) 95%, var(--muted) 5%);
  width: max-content;
  justify-items: start;
  align-items: end;
}

.poly-global__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.poly-global__field--beats {
  grid-column: 1;
  grid-row: 1;
  inline-size: calc(var(--poly-fraction-width) - 0.5rem);
}

.poly-global__field--note {
  grid-column: 2;
  grid-row: 1;
}

.poly-global__field--tempo {
  grid-column: 3;
  grid-row: 1;
}

.poly-global__field--signature-den {
  grid-column: 1;
  grid-row: 2;
  inline-size: calc(var(--poly-fraction-width) - 0.5rem);
  justify-self: start;
}

.poly-global__field--repeat {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
  justify-self: start;
  inline-size: clamp(4.6rem, 18vw, 6rem);
}

.poly-global__label {
  font-weight: 600;
  font-size: 0.9rem;
}

.poly-global__field--beats .poly-global__label,
.poly-global__field--signature-den .poly-global__label,
.poly-global__field--repeat .poly-global__label {
  text-align: center;
}

.poly-global__input {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid color-mix(in oklab, var(--muted) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--paper) 98%, var(--muted) 2%);
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
  min-height: 2.25rem;
  box-sizing: border-box;
  text-align: center;
}

.poly-global__field--beats .poly-global__input {
  width: 100%;
  text-align: center;
}

.poly-global__field--tempo .poly-global__input {
  inline-size: calc(6ch + 2.2rem);
  text-align: center;
}

.poly-global__field--note .poly-select--note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid color-mix(in oklab, var(--muted) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--paper) 98%, var(--muted) 2%);
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
  min-height: 2.25rem;
  box-sizing: border-box;
  inline-size: clamp(3.1rem, 10vw, 3.6rem);
  min-inline-size: 0;
  padding-inline: 0.45rem;
  text-align: center;
}

.poly-global__field--signature-den .poly-select {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid color-mix(in oklab, var(--muted) 45%, transparent);
  border-radius: 12px;
  background: color-mix(in oklab, var(--paper) 98%, var(--muted) 2%);
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: inherit;
  min-height: 2.25rem;
  box-sizing: border-box;
  width: 100%;
  text-align: center;
}

.poly-global__field--repeat .poly-global__input {
  width: 100%;
  text-align: center;
}

@media (max-width: 640px) {
  .poly-global__group {
    --poly-fraction-width: clamp(4.1rem, 36vw, 4.8rem);
    column-gap: 3px;
    row-gap: 10px;
    padding: 12px;
  }

  .poly-global__field--tempo .poly-global__input {
    inline-size: calc(6ch + 1.8rem);
  }

  .poly-global__field--note .poly-select--note {
    inline-size: clamp(3rem, 28vw, 3.4rem);
  }
  
  .poly-global__field--repeat {
    inline-size: clamp(4.4rem, 28vw, 5.4rem);
  }
}
/* ==== poly-global simple layout END ==== */



.poly-global__play {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: color-mix(in oklab, var(--accent, var(--ink)) 82%, var(--paper) 18%);
  color: var(--paper);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.poly-global__play:hover,
.poly-global__play:focus-visible {
  background: color-mix(in oklab, var(--accent, var(--ink)) 70%, var(--paper) 30%);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent, var(--ink)) 18%, transparent);
  outline: none;
}

.poly-global__play:active {
  transform: scale(0.95);
}

.poly-global__play:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.poly-global__play--loading {
  cursor: progress;
}

.poly-global__play-icon {
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: inherit;
}

.poly-global__play-icon--stop {
  opacity: 0;
  transform: scale(0.6);
}

.poly-global__play[aria-pressed="true"] .poly-global__play-icon--play {
  opacity: 0;
  transform: scale(0.6);
}

.poly-global__play[aria-pressed="true"] .poly-global__play-icon--stop {
  opacity: 1;
  transform: scale(1);
}

.poly-global__play-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.poly-global__play--loading .poly-global__play-icon {
  opacity: 0;
  transform: scale(0.6);
}

.poly-global__play--loading .poly-global__play-loader {
  opacity: 1;
}

.poly-global__play-loader .btn-loader-svg {
  width: 72px;
  height: 36px;
  display: block;
}

.poly-global__play-loader .btn-loader-path {
  stroke: currentColor;
  stroke-width: 14;
}



.poly-global__play-icon svg {
  width: 28px;
  height: 28px;
}
