/* The average face (/demos/average/, average.js). Landscape: the blend on the left, the tags on the right (scrolling on
   their own when the screen is short). Portrait: the blend on top, a line of tags per group underneath, each scrolling
   sideways. The blend is as big as its room allows (container query units). */
.avg { --pad: clamp(var(--space-3), 2vmin, var(--space-6)); display: grid; grid-template-columns: minmax(0, 1fr) clamp(250px, 32vw, 380px); grid-template-rows: minmax(0, 1fr); gap: var(--space-5); padding: var(--pad); }
.avg [hidden] { display: none !important; }

.avg-view { container-type: size; display: grid; align-content: center; justify-items: center; gap: var(--space-3); min-width: 0; min-height: 0; }
.avg-view > * { --fw: min(100cqw, (100cqh - 76px) * 0.75, 600px); }
.avg-frame { position: relative; width: var(--fw); aspect-ratio: 3 / 4; overflow: hidden; border-radius: var(--radius-lg); background: var(--paper-3); box-shadow: var(--shadow-lg); transition: background-color 700ms var(--ease-out); }
.avg-frame canvas { display: block; width: 100%; height: 100%; }
.avg-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: var(--space-6); color: var(--ink-2); font-weight: 600; text-align: center; }
.avg-count { max-width: var(--fw); min-height: 1.4em; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--text-sm); font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.avg-who { display: flex; align-items: center; justify-content: center; min-height: 28px; max-width: var(--fw); overflow: hidden; }
.avg-who span { flex: none; width: 28px; height: 28px; margin-left: -7px; border: 2px solid var(--paper); border-radius: 50%; box-sizing: content-box; animation: who-in 300ms var(--ease-out) both; }
.avg-who span:first-child { margin-left: 0; }
@keyframes who-in { from { opacity: 0; translate: 0 4px; } }

.avg-panel { display: grid; gap: var(--space-4); align-content: start; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.avg-group { display: grid; gap: var(--space-2); min-width: 0; }
.avg-label { color: var(--ink-3); font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.avg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.avg .chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.avg .chip.is-empty { opacity: 0.4; }
/* the age slider: two range inputs on one track, the stretch between their handles filled */
.avg-age .avg-chips { flex-wrap: nowrap; align-items: center; gap: var(--space-3); }
.avg-range { --lo: 0; --hi: 1; --thumb: 22px; position: relative; flex: 1 1 auto; min-width: 140px; max-width: 280px; height: 32px; }
.avg-range::before, .avg-range-fill { content: ""; position: absolute; top: 50%; height: 4px; translate: 0 -50%; border-radius: 2px; }
.avg-range::before { left: calc(var(--thumb) / 2); right: calc(var(--thumb) / 2); background: var(--paper-3); }
.avg-range-fill { left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--lo)); right: calc(var(--thumb) / 2 + (100% - var(--thumb)) * (1 - var(--hi))); background: var(--ink); }
.avg-range input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; }
.avg-range input::-webkit-slider-runnable-track { background: none; }
.avg-range input::-moz-range-track { background: none; }
.avg-range input::-webkit-slider-thumb { width: var(--thumb); height: var(--thumb); border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); box-shadow: var(--shadow-sm); cursor: grab; pointer-events: auto; -webkit-appearance: none; appearance: none; }
.avg-range input::-moz-range-thumb { width: var(--thumb); height: var(--thumb); box-sizing: border-box; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); box-shadow: var(--shadow-sm); cursor: grab; pointer-events: auto; }
.avg-range input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.avg-range input:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.avg-age-out { flex: none; min-width: 4.6em; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
/* the face switches: the feature's name, then its options; a line each where there is room */
.avg-face .avg-chips { gap: var(--space-2); }
.avg-switch { flex: none; align-items: center; }
.avg-switch-name { min-width: 4.6em; padding: 0 var(--space-2) 0 var(--space-3); color: var(--ink-2); font-size: var(--text-sm); font-weight: 600; }
.avg-switch button.is-empty { opacity: 0.4; }
.avg-try .chip { border-style: dashed; }
.avg-try .chip[aria-pressed="true"] { border-style: solid; }

@media (orientation: portrait) {
  .avg { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: var(--space-3); }
  .avg-panel { gap: var(--space-2); overflow: visible; }
  .avg-group { grid-template-columns: 4.2em minmax(0, 1fr); align-items: center; gap: var(--space-2); }
  .avg-label { font-size: 10px; }
  .avg-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; padding-right: 24px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .avg-chips::-webkit-scrollbar { display: none; }
  .avg .chip { flex: none; min-height: 30px; }
  .avg-age .avg-chips { overflow: visible; padding-right: 0; -webkit-mask-image: none; mask-image: none; }
}
