.body-words {
  container-type: inline-size;
  min-width: 0;
  color: var(--ink);
  font: 500 1.12rem/1.4 var(--serif);
}
.body-words [hidden] { display: none; }
.body-words button { cursor: pointer; color: inherit; font: inherit; }
.bw-toggle, .bw-list-toggle {
  min-height: 44px; padding: 4px 0; border: 0; background: none;
  text-decoration: underline dotted; text-decoration-color: var(--gold-lo); text-underline-offset: 4px;
}
.body-words .bw-toggle { color: var(--gold-hi); }
.bw-toggle::before { content: '✦' / ''; margin-right: .45em; color: var(--gold); }
.bw-panel { --tint: var(--gold); padding-bottom: 6px; }
.bw-graphic { width: min(100%, 25rem); margin: 4px auto 0; }
.bw-caption, .bw-label { font: 500 .72rem/1.45 var(--caps); letter-spacing: .13em; text-transform: uppercase; }
.bw-caption { color: var(--tint); text-align: center; margin: 0; }
.bw-flower {
  position: relative; isolation: isolate;
  width: 100%; aspect-ratio: 1; min-height: 14.5rem;
  background: radial-gradient(closest-side, rgba(72, 53, 113, .18), transparent);
}
.bw-flower > svg {
  position: absolute; inset: 0; margin: auto; width: 100%; height: 100%;
  overflow: visible;
}
.bw-petal { cursor: pointer; }
.bw-blade { fill: currentColor; fill-opacity: .16; stroke: currentColor; stroke-opacity: .75; stroke-width: 1.2; }
.bw-vein { fill: none; stroke: currentColor; stroke-opacity: .5; }
.bw-flower[data-open="true"] > svg { transform: scale(.52); }
.bw-flower[data-open="true"] .bw-petal { opacity: .55; }
.bw-flower[data-open="true"] .bw-petal[data-active="true"] { opacity: 1; filter: drop-shadow(0 0 3px currentColor); }
.bw-petal[data-active="true"] .bw-blade { fill-opacity: .5; stroke-opacity: 1; }
.bw-petal[data-active="true"] .bw-vein { stroke-opacity: .9; }

.body-words .bw-family {
  position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%);
  padding: 0 2px; min-width: 44px; min-height: 44px; background: none; border: 0;
  color: #fff; text-shadow: 0 1px 3px #0d0a26, 0 0 4px #0d0a26;
  font: 600 clamp(.66rem, 3.4cqi, .85rem)/1.2 var(--caps); letter-spacing: .035em;
}
.body-words .bw-family[aria-expanded="true"] {
  left: 50%; top: 50%; color: #241735; text-shadow: none;
  font: 600 1.05rem/1 var(--sans);
}
.bw-family:hover { text-decoration: underline; text-underline-offset: 3px; }

.bw-ring {
  position: absolute; inset: 0; pointer-events: none;
  display: grid; grid-template: repeat(5, minmax(44px, 1fr)) / repeat(2, minmax(0, 1fr));
  align-items: center; gap: 2px 0;
}
.body-words .bw-word, .body-words .bw-chip {
  min-height: 44px; max-width: 100%; padding: 3px .6em;
  border-radius: 1.3em; border: 1px solid color-mix(in srgb, var(--tint) 54%, transparent);
  color: var(--ink); background: #14102f;
  font: 500 1.07rem/1.1 var(--serif);
}
.bw-ring .bw-word {
  pointer-events: auto; max-width: 86%; overflow-wrap: anywhere;
  font-size: clamp(.93rem, 5.1cqi, 1.2rem);
}
.body-words .bw-word:hover, .body-words .bw-chip:hover { border-color: var(--tint); }
.body-words .bw-word[aria-pressed="true"] {
  background: color-mix(in srgb, var(--tint) 22%, #15112e); color: #fff; border-color: var(--tint);
  text-decoration: underline; text-underline-offset: .18em; font-weight: 600;
}
.bw-ring .bw-word:nth-child(1) { grid-area: 1 / 1 / 2 / 3; justify-self: center; }
.bw-ring .bw-word:nth-child(2) { grid-area: 2 / 2; justify-self: end; margin-right: 12%; }
.bw-ring .bw-word:nth-child(3) { grid-area: 3 / 2; justify-self: end; }
.bw-ring .bw-word:nth-child(4) { grid-area: 4 / 2; justify-self: end; margin-right: 12%; }
.bw-ring .bw-word:nth-child(5) { grid-area: 5 / 1 / 6 / 3; justify-self: center; }
.bw-ring .bw-word:nth-child(6) { grid-area: 4 / 1; justify-self: start; margin-left: 12%; }
.bw-ring .bw-word:nth-child(7) { grid-area: 3 / 1; justify-self: start; }
.bw-ring .bw-word:nth-child(8) { grid-area: 2 / 1; justify-self: start; margin-left: 12%; }

/* The center control needs its own 44px between the two side words. */
.bw-ring .bw-word:nth-child(3), .bw-ring .bw-word:nth-child(7) { max-width: calc(100% - 24px); }

.bw-hint { margin: 4px 0 6px; color: var(--ink-soft); text-align: center; font-size: 1.06rem; }
.bw-trying { margin: 12px 0 4px; padding: 10px 0 0; border-top: 1px solid var(--panel-line); }
.bw-label { color: var(--tint); }
.bw-chips { display: flex; flex-wrap: wrap; gap: 5px 7px; margin: 5px 0 0; }
.body-words .bw-chip { color: var(--gold-hi); background: transparent; border-color: var(--panel-line); }
.bw-cross { margin-left: .38em; }
.body-words .bw-list-toggle { color: var(--gold); font: 500 .83rem/1.4 var(--sans); }
.bw-list-family { margin: 2px 0 14px; padding: 0; min-width: 0; border: 0; }
.bw-list-family .bw-label { margin-bottom: 4px; }
.bw-list-family .bw-word { margin: 2px 5px 2px 0; }

/* Five rows keep neighboring family labels and their tap targets apart on small phones. */
@container (max-width: 17rem) {
  .bw-flower:not([data-open="true"]) { display: grid; grid-template: repeat(5, 1fr) / repeat(2, minmax(0, 1fr)); align-items: center; }
  .bw-flower:not([data-open="true"]) .bw-family { position: relative; inset: auto; transform: none; }
  .bw-family:nth-of-type(1) { grid-area: 1 / 1 / 2 / 3; justify-self: center; }
  .bw-family:nth-of-type(2) { grid-area: 2 / 2; justify-self: center; }
  .bw-family:nth-of-type(3) { grid-area: 3 / 2; justify-self: end; }
  .bw-family:nth-of-type(4) { grid-area: 4 / 2; justify-self: center; }
  .bw-family:nth-of-type(5) { grid-area: 5 / 1 / 6 / 3; justify-self: center; }
  .bw-family:nth-of-type(6) { grid-area: 4 / 1; justify-self: center; }
  .bw-family:nth-of-type(7) { grid-area: 3 / 1; justify-self: start; }
  .bw-family:nth-of-type(8) { grid-area: 2 / 1; justify-self: center; }
}
/* At very narrow widths, keep the flower and place words beneath its center control. */
@container (max-width: 12rem) {
  .body-words .bw-family { font-size: .61rem; min-width: 36px; }
  .bw-flower[data-open="true"] { aspect-ratio: auto; padding-top: 5rem; }
  .bw-flower[data-open="true"] > svg { inset: 0 0 auto; height: 5rem; transform: none; }
  .bw-flower[data-open="true"] .bw-family { top: 2.5rem; }
  .bw-ring { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .bw-ring .bw-word:nth-child(n) { margin: 0; max-width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .bw-flower > svg { transition: transform .4s ease-out; }
  .bw-ring:not([hidden]) { animation: bw-bloom .32s ease-out; }
  @keyframes bw-bloom { from { opacity: 0; transform: scale(.94); } }
}
