/* finale.css: WS5 Finale and physics (the pile, the debris registers, the groove footer, the 'dance.' bop) */

/* ---------- the pile (F1) ---------- */

.finale .pile { touch-action: pan-y; }
.finale .pile:focus-visible { outline-offset: -10px; }
.finale .pile .p-ch { touch-action: pan-y; }
.finale .pile .p-ch.out { visibility: hidden; }
.finale .pile .p-ch.grab { cursor: grabbing; }
.finale .pile .p-ch.held { scale: 1.06; }

/* ---------- debris registers (F2): each piece in its own typeface ---------- */

.finale .pile .p-deb {
  font-size: clamp(28px, 5vw, 100px);
  line-height: .92;
  padding: .04em .05em 0;
  white-space: nowrap;
}
.finale .pile .p-deb.is-word { font-size: clamp(18px, 3.4vw, 60px); }

.finale .pile .r-hero    { font-family: var(--serif); font-style: normal; text-transform: none; font-variation-settings: "opsz" 144, "wght" 900, "SOFT" 100, "WONK" 1; }
.finale .pile .r-ice     { font-family: var(--serif); font-style: italic; text-transform: none; font-variation-settings: "opsz" 144, "wght" 200, "SOFT" 100; }
.finale .pile .r-t-markets { font-family: var(--flex); text-transform: uppercase; font-variation-settings: "wdth" 25, "wght" 860, "opsz" 144; }
.finale .pile .r-t-yours { font-family: var(--flex); text-transform: uppercase; font-variation-settings: "wdth" 100, "wght" 1000, "opsz" 144; }
.finale .pile .r-t-house { font-family: var(--serif); font-style: normal; text-transform: none; font-variation-settings: "opsz" 144, "wght" 900, "WONK" 1; }
.finale .pile .r-stairs  { font-family: var(--flex); text-transform: none; font-variation-settings: "wdth" 25, "wght" 1000, "opsz" 144; }
.finale .pile .r-word    { font-family: var(--serif); font-style: normal; text-transform: none; font-variation-settings: "opsz" 72, "wght" 330; }
.finale .pile .r-misc    { font-family: var(--flex); font-variation-settings: "wdth" 100, "wght" 700, "opsz" 144; }

/* ---------- the flat pile: reduced motion, or no Matter (F1) ---------- */

.finale .pile.flat {
  inset: auto var(--gutter) var(--pile-foot, 100px);
  display: block;
}
.finale .pile.flat > .p-ch { display: none; }
.pile-flat { display: none; }
.finale .pile.flat > .pile-flat { display: block; opacity: 0; transition: opacity .3s linear; }
.finale .pile.flat.landed > .pile-flat { opacity: 1; }
.pile-flat .pf-line {
  display: block;
  width: max-content;
  font-family: var(--flex);
  font-variation-settings: "wdth" 151, "wght" 1000, "opsz" 144;
  line-height: .78;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--ink);
}
.pile-flat .pf-ch { transition: color .3s linear; }
.pile-flat .pf-ch.tint { color: var(--paper); }
.pile-flat .pf-debris {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: .15em .5em;
  margin-top: .5em;
  font-size: clamp(14px, 2.2vw, 36px);
  line-height: 1;
  color: var(--ink);
}
.pile-flat .pf-deb.is-word { font-size: .72em; }

/* ---------- the footer: dance, groove readout, motion chip, verdict (F2/F3) ---------- */

.finale-foot .foot-verdict { flex: 0 1 auto; min-width: 0; max-width: 40em; }
.finale-foot .foot-play {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 14px;
  pointer-events: none;
}
.finale-foot .foot-play:empty { display: none; }
.finale-foot .foot-play > * { pointer-events: auto; }
/* the hint sits in the margin under the controls: below the physics floor, so no letter ever covers it */
.finale-foot .foot-play > .hint {
  position: absolute; left: 0; top: calc(100% + 9px);
  margin: 0;
  white-space: nowrap;
  pointer-events: none;
}
.finale-foot .dance,
.finale-foot .motion-chip {
  appearance: none; -webkit-appearance: none;
  background: none; color: inherit;
  border: 1px solid currentColor; border-radius: 99px;
  padding: 8px 14px;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.finale-foot .dance:hover,
.finale-foot .motion-chip:hover { background: var(--ink); color: var(--signal); }
.finale-foot .motion-chip[aria-pressed="true"] { background: var(--ink); color: var(--signal); }
.finale-foot .motion-chip.denied { opacity: .5; }
.finale-foot .motion-chip[hidden] { display: none; }
.finale-foot .groove {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: .55;
}
.finale-foot .groove.on { opacity: 1; }

/* phone verdict, under the punchline */
.finale-copy .finale-verdict { display: none; }

/* ---------- 'dance.' bop (F3) ---------- */

.finale-line em {
  display: inline-block;
  transform-origin: 50% 80%;
}

@media (pointer: coarse) {
  .finale-foot .dance,
  .finale-foot .motion-chip { min-height: 44px; padding: 13px 16px; }
}

@media (max-width: 720px) {
  .finale-copy .finale-verdict {
    display: block;
    max-width: 30ch;
    opacity: 0;
    transition: opacity .4s linear;
  }
  .finale-copy .finale-verdict.on { opacity: .85; }
  /* phones: the footer is a column; anchor the hint under the whole footer instead */
  .finale-foot .foot-play { position: static; }
  .finale-foot .foot-play > .hint { top: calc(100% + 6px); max-width: calc(100vw - 2 * var(--gutter)); overflow: hidden; text-overflow: ellipsis; }
}
