/* On this post the prose and examples share the full article column. */
.post-body:has(> .score-artifact) { max-width: none; }
.post-body > .score-artifact,
.post-body:has(> .score-artifact) > .codehilite {
  box-sizing: border-box;
  width: 96%;
  margin: 1.5rem auto;
}

.ballade {
  position: relative;
  isolation: isolate;
  min-height: 4rem;
  padding: clamp(8px, 1.3vw, 16px);
}

/* Clip only the sheet of paper so the playback controls stay interactive. */
.paper { filter: drop-shadow(0 2px 3px rgb(72 51 27 / 18%)); }
.paper::before {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: -1;
  inset: 0;
  /* Small nicks along the edges of the paper. */
  clip-path: polygon(
    0 0, 26% 0, calc(26% + 2px) 3px, calc(26% + 4px) 1px, calc(26% + 6px) 0,
    100% 0,
    100% 62%, calc(100% - 4px) calc(62% + 3px), 100% calc(62% + 5px),
    100% 100%, 36% 100%, calc(36% - 3px) calc(100% - 3px), calc(36% - 7px) 100%,
    0 100%, 0 32%, 3px calc(32% - 2px), 0 calc(32% - 5px)
  );
  background: url("paper.svg"), radial-gradient(ellipse at 42% 38%, #fffdf5 10%, #f8f3e5 87%, #f2ead7);
  box-shadow: inset 0 0 0 1px rgb(113 89 51 / 14%);
  filter: url("paper.svg#deckle");
}

.paper .ballade-ink {
  filter: url("paper.svg#ink");
}

.ballade .vf-score-heading text {
  transform-box: fill-box;
  transform-origin: left bottom;
  transform: scale(.74);
}

.ballade .vf-score-heading text:first-of-type {
  transform-origin: center bottom;
  transform: scale(.5824);
}

.ballade .vf-score-heading .composer-subtitle {
  text-anchor: middle;
  font-weight: normal;
  transform-origin: center bottom;
}

.sheet-loading:not([hidden]) {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.25em 0.6em;
  background: #f9f5e8;
  color: #555;
  font-size: 0.9rem;
  pointer-events: none;
}

.sheet-loading::before {
  content: "";
  width: 0.8em;
  height: 0.8em;
  border: 2px solid #ddd;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ballade-spin 0.8s linear infinite;
}

@keyframes ballade-spin {
  to { transform: rotate(1turn); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet-loading::before { animation: none; }
}

/* Keep the compact engraving studies in proportion to the article's text. */
.demo-card {
  color: #332f29;
}
.demo-card iframe { display: block; width: 100%; border: 0; }
.engraving, .comparison { padding: clamp(12px, 2.5vw, 26px); }
.engraving > div { max-width: 32rem; margin: auto; }
#beam-study { max-width: 22rem; }
#ornament-study { max-width: 26rem; }
.comparison { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6%; }
.comparison figure { margin: 0; min-width: 0; }
.comparison figcaption { font-size: .82rem; font-weight: 600; color: #665749; margin-bottom: .6rem; }
.comparison iframe { height: 5rem; }
.demo-controls {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem 1rem;
  padding: .65rem 1rem; border-bottom: 1px solid #e1dbcf;
  font-size: .84rem; font-weight: 600;
}
.demo-controls button { margin-left: auto; font: inherit; color: inherit; cursor: pointer; background: transparent; border: 1px solid #b6ad9e; border-radius: 4px; padding: .2em .65em; }
.demo-controls button:disabled { opacity: .5; cursor: default; }
.demo-controls input { flex: 1; min-width: 6rem; accent-color: #805735; cursor: ew-resize; }
.demo-controls output { font-variant-numeric: tabular-nums; font-weight: 400; }
.reflow-area { padding: 12px 8px; }
#choir-score { box-sizing: border-box; margin: auto; }
.edit-area {
  display: grid;
  grid-template: minmax(0, 1fr) / max-content minmax(0, 1fr);
  height: 14rem;
  border-bottom: 1px solid #ded9cf;
}
.editor-gutter {
  grid-area: 1 / 1;
  overflow: hidden;
  padding: .8rem .6rem;
  color: #756f64;
  border-right: 1px solid #ded9cf;
  text-align: right;
  user-select: none;
}
.editor-gutter span { display: block; min-width: 2ch; white-space: pre; }
.post-body .edit-area pre, .post-body .edit-area textarea, .post-body .edit-area code, .editor-gutter span {
  box-sizing: border-box; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: normal; tab-size: 2; white-space: pre; text-transform: none;
  background: transparent; border: 0; border-radius: 0; margin: 0; box-shadow: none;
}
.post-body .edit-area textarea, .post-body .edit-area pre { grid-area: 1 / 2; position: relative; width: 100%; height: 100%; min-width: 0; padding: .8rem .75rem; }
.post-body .edit-area pre { overflow: hidden; pointer-events: none; }
.post-body .edit-area code { display: block; width: max-content; padding: 0; }
.post-body .edit-area textarea { overflow: auto; resize: none; color: inherit; caret-color: #352d26; }
.post-body .highlighted textarea { color: transparent; }
.post-body .edit-area textarea:focus-visible { outline: 2px solid #93764c; outline-offset: -2px; }
.edit-area .token.comment { color: #64705f; }
.edit-area .token.string { color: #77502d; }
.edit-area .token.keyword, .edit-area .token.boolean { color: #6b4284; }
.edit-area .token.duration, .edit-area .token.function, .edit-area .token.number { color: #245f75; }
.editor-error:not(:empty) { padding: .6rem 1rem; color: #872f20; background: #fff1e7; font-size: .85rem; }


.ballade .edition-title, .ballade .edition-credit {
  transform-box: fill-box;
  transform-origin: center bottom;
}
.ballade .edition-title { transform: scale(.62); }
.ballade .edition-credit { transform: scale(.75); font-weight: normal; }
.ballade.compact-footer { padding-bottom: 1rem; }

.short-editor .edit-area { height: 6rem; }
.post-body .formatter-test img {
  display: block;
  width: 100%;
  height: auto;
  padding: 0;
  border: 0;
  box-shadow: none;
}
