/* ABC Areal is licensed: place the file in /fonts (see fonts/README.md). One variable file covers every weight. */
@font-face {
  font-family: "ABC Areal";
  src: url("../fonts/ABCArealVariable.woff2") format("woff2");
  font-weight: 400 700;
  font-style: oblique 0deg 12deg; /* the slant axis: italic and oblique use Areal's own slant, not a skewed copy */
  font-display: swap;
}

:root {
  /* The inset (the smaller of the two views, top right): small, so the main view can be large. */
  --inset-w: min(26vw, 340px);
  --inset-h: min(34vh, 290px);
  --bg: #f2f1ec;
  --ink: #161616;
  --ink-quiet: #6b6a65;
  --rule: #d9d7cf;
  --surface: rgba(242, 241, 236, 0.9);
  --field: #fff;
  --hover: rgba(0, 0, 0, 0.05);
  --accent: #2f6b4f;
  --imagined: #4b4a9e;
  --font: "ABC Areal", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --gutter: 24px;
  /* Areal's dark-mode axis: thins the strokes a little, so light type on dark doesn't look bolder than dark on light. */
  --drkm: 0;
  color-scheme: light;
}

/* Dark: chosen with the header's switch (data-theme, set by js/theme.js), else the system's setting. */
:root[data-theme="dark"] {
  --bg: #111110;
  --ink: #ecebe6;
  --ink-quiet: #9a988f;
  --rule: #2e2d2a;
  --surface: rgba(17, 17, 16, 0.9);
  --field: #1b1b1a;
  --hover: rgba(255, 255, 255, 0.07);
  --accent: #6fb08c;
  --imagined: #9b98e0;
  --drkm: 1;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --ink: #ecebe6;
    --ink-quiet: #9a988f;
    --rule: #2e2d2a;
    --surface: rgba(17, 17, 16, 0.9);
    --field: #1b1b1a;
    --hover: rgba(255, 255, 255, 0.07);
    --accent: #6fb08c;
    --imagined: #9b98e0;
    --drkm: 1;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

/* On every element, since a `font:` shorthand (as in the nav) resets it. Weight and slant are set with font-weight and
   font-style, so this one setting only ever carries the dark-mode axis. */
*, ::before, ::after {
  font-variation-settings: "DRKM" var(--drkm) !important;
}

/* The top nav is added by js/nav.js, after the page can first be drawn. Until it's there, its space is kept at the
   top of a reading page, so nothing drops down when it arrives (and a page crossfades in where it will stay); the
   height is the nav's own, as nav.js last measured it (kept by the theme script in each page's head). */
main.page:not(:has(> .site-nav))::before { content: ''; display: block; height: var(--nav-space, 74px); }

/* Moving between pages: a short crossfade instead of a blank reload (cross-document view transitions; browsers
   without them just load the page). None for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; animation-timing-function: ease-out; }
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* In Bird and Song the canvas fills its stage, main or small, not the window (Song's form is #scene, and as the small
   view it must shrink with it). */
.stage #scene {
  position: static;
}

.masthead {
  position: fixed;
  top: var(--gutter);
  left: var(--gutter);
  right: var(--gutter);
  pointer-events: none;
}

.masthead__title {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.masthead__subtitle {
  margin: 6px 0 0;
  max-width: 34em;
  font-size: 15px;
  line-height: 1.4;
  color: var(--ink-quiet);
}

.panel {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter);
  width: 300px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(6px);
}

.panel__label {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-quiet);
}

.panel__name {
  margin: 4px 0 12px;
  font-size: 17px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.panel__credit {
  margin: -8px 0 12px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-quiet);
}

.panel__credit a {
  color: inherit;
}

.panel__picker {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}

.panel__picker[hidden] {
  display: none;
}

.select {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.panel__meta {
  display: flex;
  gap: 24px;
  margin: 0 0 16px;
  font-size: 13px;
}

.panel__meta dt {
  color: var(--ink-quiet);
}

.panel__meta dd {
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
}

.panel__actions {
  display: flex;
  gap: 8px;
}

.panel__hint {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-quiet);
}

.button {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.button:hover {
  background: var(--hover);
}

.button--primary {
  background: var(--ink);
  color: var(--bg);
}

.button--primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

.legend {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-quiet);
}

.dropzone {
  position: fixed;
  inset: 12px;
  display: grid;
  place-items: center;
  border: 1.5px dashed var(--ink);
  background: var(--surface);
  font-size: 20px;
}

.dropzone[hidden] {
  display: none;
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .panel {
    right: var(--gutter);
    width: auto;
  }

  .legend {
    display: none;
  }
}

/* Phrase map (map.html) ------------------------------------------------------ */

.panel__badge {
  display: inline-block;
  margin: -6px 0 10px;
  padding: 2px 8px;
  font-size: 12px;
  border: 1px solid currentColor;
}

.panel__badge--real {
  color: var(--accent);
}

.panel__badge--imagined {
  color: var(--imagined);
}

.panel__subtitle {
  margin: -8px 0 10px;
  font-size: 13px;
  color: var(--ink-quiet);
}

.panel__facts {
  margin: 4px 0 14px;
  font-size: 13px;
}

.panel__facts div {
  margin-top: 6px;
}

.panel__facts dt {
  font-size: 12px;
  color: var(--ink-quiet);
}

.panel__facts dd {
  margin: 1px 0 0;
  overflow-wrap: anywhere;
}

.panel__facts a {
  color: inherit;
}

.meter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-quiet);
}

.meter__track {
  position: relative;
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--accent), var(--imagined));
}

.meter__dot {
  position: absolute;
  top: -4px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: var(--ink);
}


.map-legend {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-quiet);
}

.map-legend__mode select {
  margin-left: 4px;
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
}

.map-legend__items {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  max-height: 84px;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.map-legend__items li::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--swatch);
}

.map-legend__items li.map-legend__ramp {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.map-legend__items li.map-legend__ramp::before {
  display: none;
}

.map-legend__bar {
  flex: 1;
  height: 8px;
  min-width: 60px;
}

/* Aviary (aviary.html) ------------------------------------------------------- */

.aviary-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.aviary-label {
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  transform: translate(8px, -50%);
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg);
}

.aviary-labels--bodies .aviary-label {
  padding-left: 24px; /* clear of the body, whose centre the name starts at */
}

.aviary-label--selected {
  font-weight: 500;
}

.aviary-label--imagined {
  color: var(--imagined);
  font-style: italic;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.segmented button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.segmented button[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.blend {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 8px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-quiet);
}

.blend label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.blend select:not(.select) {
  height: 34px;
  font: inherit;
  font-size: 13px;
}

.blend input[type="range"] {
  grid-column: 1 / -1;
  accent-color: var(--imagined);
}

.axis-label {
  font-size: 11px;
  color: var(--ink-quiet);
  white-space: nowrap;
  transform: translate(-50%, -50%);
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg);
}

.axis-label--name {
  color: var(--ink);
}

.toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 10px 0 4px;
  font-size: 13px;
}

.toggle .panel__hint {
  margin: 0;
  flex-basis: 100%;
}

/* Song and Bird (map.html, aviary.html): one minimal layout ------------------------------------------- */
/* The form fills the window; the map (phrase map or aviary) is feathered into the top right. V or ⇄ swaps
   them (body.map-main). Everything else is text over the scene: header, keys, what you hear, options. */

.experience .masthead {
  z-index: 10; /* over the map's caption (5) and the rail, so the More menu opens over them */
  right: auto;
}

.stage {
  position: fixed;
  overflow: hidden;
}

.stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stage__labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

body:not(.map-main) #form-stage,
.map-main #map-stage {
  inset: 0;
  z-index: 0;
}

body:not(.map-main) #map-stage,
.map-main #form-stage {
  top: 0;
  right: 0;
  width: var(--inset-w);
  height: var(--inset-h);
  z-index: 1;
  /* Feathered: the inset fades into the page instead of sitting in a box. */
  -webkit-mask-image: radial-gradient(closest-side, #000 62%, transparent 100%);
  mask-image: radial-gradient(closest-side, #000 62%, transparent 100%);
}

.latent-slice {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.latent-slice[hidden],
.slice-on #map {
  visibility: hidden;
}

.stage__swap {
  position: absolute;
  z-index: 2; /* over the latent slice's canvas, which is added after it */
  left: 50%;
  bottom: 14%;
  transform: translateX(-50%);
  padding: 2px 8px;
  border: 0;
  background: none;
  color: var(--ink-quiet);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.stage:hover .stage__swap,
.stage__swap:focus-visible {
  opacity: 1;
}

body:not(.map-main) #form-stage .stage__swap,
.map-main #map-stage .stage__swap {
  display: none;
}

/* Text over the scene keeps a halo of the background so it reads over the form. */
.keys,
.hearing,
.experience .masthead,
.map-settings {
  text-shadow: 0 0 4px var(--bg), 0 0 8px var(--bg);
}

/* The map's caption is its settings: "latent by species", each word a dropdown sized to its text. Centred under
   the inset, or level with the header when the map is the main view; the legend (when short) sits under it. */
.map-settings {
  position: fixed;
  z-index: 5;
  top: calc(var(--inset-h) - 34px);
  right: calc(var(--inset-w) / 2);
  transform: translateX(50%);
  text-align: center;
}

.map-main .map-settings {
  top: 24px; /* the header's top: the caption shares its line */
  right: auto;
  left: 50%;
  transform: translateX(-50%);
}

/* Under the small map, the caption keeps to its width, wrapping when "colored by sound type in 3-D" is too long. */
body:not(.map-main) .map-settings {
  width: max-content;
  max-width: var(--inset-w);
}

body:not(.map-main) .map-caption {
  white-space: normal;
}

@media (max-width: 1000px) {
  .map-main .map-settings {
    top: 60px; /* under the header: "latent, colored by species" would run into the nav */
  }
}

.map-caption {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-quiet);
  white-space: nowrap;
}

.map-main .map-caption {
  padding-top: 3.5px; /* onto the nav links' baseline (they sit under the 16 px name) */
  font-size: 13px;
}

/* Song's "latent" isn't a choice (its map is the model's own space), so it reads as the caption's plain words do. */
.map-caption__fixed {
  color: var(--ink-quiet);
  cursor: help;
}

/* A caption word that opens a dropdown in the page's own style (stage.js builds it over the hidden select). */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__button {
  padding: 0 0 1px;
  border: 0;
  border-bottom: 1px dotted var(--ink-quiet);
  background: none;
  color: var(--ink);
  font: inherit;
  text-shadow: inherit;
  cursor: pointer;
}

.dropdown__button::after {
  content: " \25BE";
  font-size: 0.8em;
  color: var(--ink-quiet);
}

.dropdown__button:hover,
.dropdown__button[aria-expanded="true"] {
  border-bottom-style: solid;
  border-bottom-color: var(--ink);
}

.dropdown__panel {
  position: absolute;
  z-index: 6;
  top: calc(100% + 8px);
  left: 50%;
  width: max-content;
  min-width: 140px;
  max-width: 240px;
  padding: 6px 0;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  text-align: left;
  text-shadow: none;
  white-space: normal;
}

.dropdown__panel[hidden],
.dropdown[hidden] {
  display: none;
}

.dropdown__list {
  max-height: min(50vh, 360px); /* long lists (go to a species) scroll */
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.dropdown__list li {
  position: relative;
  padding: 4px 14px 4px 24px;
  font-size: 13px;
  color: var(--ink-quiet);
  cursor: pointer;
  outline: none;
}

.dropdown__list li:hover,
.dropdown__list li:focus-visible {
  color: var(--ink);
  background: var(--hover);
}

.dropdown__list li[aria-selected="true"] {
  color: var(--ink);
}

/* The chosen one: a small dot in the margin. */
.dropdown__list li[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--ink);
}

.dropdown__note {
  margin: 6px 0 0;
  padding: 8px 14px 2px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-quiet);
}

.dropdown__note[hidden] {
  display: none;
}

.map-settings .map-legend__items {
  justify-content: center;
  max-width: 300px;
  max-height: none;
  margin: 6px auto 0;
  font-size: 11px;
  color: var(--ink-quiet);
  overflow: visible;
}

.map-settings .map-legend__ramp {
  justify-content: center;
}

.map-settings .map-legend__bar {
  flex: 0 0 64px;
  height: 6px;
}

.map-settings .map-legend__items[hidden] {
  display: none;
}

/* The keys under the map inset (when the sound form is the main view): stacked and centred, as wide as the inset. */
.map-settings .keys {
  position: static;
  justify-content: center;
  margin: 12px auto 0;
}

.map-settings .keys__row {
  justify-content: center;
}

.map-settings .keys__status {
  display: none; /* the reminders stay with the keys at the bottom left only */
}

/* Icon actions among the keys (somewhere new, go to): small, quiet until hovered. */
.icon-button,
.dropdown__button--icon {
  display: inline-flex;
  align-items: center;
  padding: 1px;
  border: 0;
  color: var(--ink-quiet);
  vertical-align: middle;
}

.dropdown__button--icon::after {
  content: none;
}

.icon-button:hover,
.dropdown__button--icon:hover,
.dropdown__button--icon[aria-expanded="true"] {
  color: var(--ink);
  text-decoration: none;
}

.icon-button svg,
.dropdown__button--icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* A dropdown among the keys (the kind of tour) opens upwards, away from the bottom edge. */
.keys .dropdown__panel {
  top: auto;
  bottom: calc(100% + 8px);
}

.map-settings .keys .dropdown__panel {
  top: calc(100% + 8px);
  bottom: auto;
}

/* More: secondary actions and the key reference, above the keys (below them when they sit under the map). */
.keys {
  --panel-gap: 10px;
}

.keys__row {
  position: relative;
}

.keys__more {
  color: var(--ink-quiet);
}

.keys__panel {
  position: absolute;
  z-index: 6;
  bottom: calc(100% + var(--panel-gap));
  left: 0;
  width: max-content;
  padding: 10px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  text-align: left;
  text-shadow: none;
}

.keys__panel[hidden] {
  display: none;
}

.map-settings .keys__panel {
  top: calc(100% + var(--panel-gap));
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
}

.keys__list {
  display: grid;
  grid-template-columns: auto auto;
  gap: 3px 14px;
  margin: 0;
  font-size: 11px;
}

.keys__list dt {
  color: var(--ink);
}

.keys__list dd {
  margin: 0;
}

.keys__status:empty {
  display: none;
}

/* UI hidden (\): only the two views. */
.ui-hidden .masthead,
.ui-hidden .keys,
.ui-hidden .hearing,
.ui-hidden .map-settings,
.ui-hidden .options,
.ui-hidden .stage__swap {
  display: none;
}

/* Keys, bottom left: the movement keys (lit while held) and the actions, each with its key. */
.keys {
  position: fixed;
  z-index: 2;
  left: var(--gutter);
  bottom: var(--gutter);
  display: flex;
  align-items: center; /* one bar: play, the keys, the actions */
  gap: 14px;
  font-size: 12px;
  color: var(--ink-quiet);
}

.keys__caps {
  display: grid;
  grid-template-columns: repeat(4, 24px);
  gap: 4px;
}

.keys__caps kbd {
  display: grid;
  place-items: center;
  height: 24px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  color: var(--ink-quiet);
  background: var(--bg);
  text-shadow: none;
  transition: background 0.1s, color 0.1s;
}

/* The 3-D views take every touch themselves (pinch to zoom, drag to turn); otherwise the browser sometimes treats a
   pinch as zooming the page and the view only sometimes answers. */
.stage canvas,
.latent-slice {
  touch-action: none;
}

.keys__caps kbd {
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.hearing__play {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  font: inherit;
  font-size: 10px;
  color: var(--ink);
  background: var(--bg);
  text-shadow: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

/* While a sound plays, a ring in its state's colour fills around the button with the phrase, once per loop. */
.hearing__play {
  position: relative;
  --state-colour: var(--ink);
}

.hearing__play[data-state="recorded"] { --state-colour: var(--accent); }
.hearing__play[data-state="imagined"] { --state-colour: var(--imagined); }
.hearing__play[data-state="reconstructed"] { --state-colour: color-mix(in oklab, var(--accent), var(--imagined)); }

.hearing__play.is-playing::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(var(--state-colour) calc(var(--progress, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1.5px));
  pointer-events: none;
}

.hearing__play:disabled {
  color: var(--ink-quiet);
  cursor: default;
}

/* R and F zoom: a column set a little apart. */
.keys__caps kbd[data-code="KeyR"],
.keys__caps kbd[data-code="KeyF"] {
  margin-left: 4px;
}

.hearing__play.is-down,
.keys__caps kbd.is-down {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.keys__actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.keys__row {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.action {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-shadow: inherit;
}

.action[data-label]::after {
  content: " " attr(data-label);
  color: var(--ink-quiet);
  font-size: 11px;
}

.action:hover {
  text-decoration: underline;
}

.action:disabled {
  color: var(--ink-quiet);
  cursor: default;
}

.keys__status {
  min-height: 1em;
  margin: 0;
}

/* What you are hearing, bottom right: plain text, no panel. */
.hearing {
  position: fixed;
  z-index: 2;
  right: var(--gutter);
  bottom: var(--gutter);
  max-width: 360px;
  text-align: right;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-quiet);
}

/* Three tiers: the kind of sound (a coloured word), the bird (name, Latin, its sound), where it came from (quiet,
   with icons). */
.hearing__state {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.hearing__state::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 5px 1px 0;
  border-radius: 50%;
  background: currentColor;
}

.hearing__state--recorded { color: var(--accent); }
.hearing__state--imagined { color: var(--imagined); }
.hearing__state--reconstructed { color: color-mix(in oklab, var(--accent), var(--imagined)); }

.hearing__state[hidden] {
  display: none;
}

/* Bird: the kind of sound, and for a moment after M, how an imagined one is made ("● Imagined · real rhythm"). */
.hearing__state-row {
  margin: 0;
  font-size: 11px;
}

.hearing__mode {
  opacity: 0;
  transition: opacity 0.4s;
}

.hearing__mode.is-shown {
  opacity: 1;
}

/* Dropdowns at the right edge open leftwards, inside the window. */
.hearing .dropdown__panel {
  left: auto;
  right: 0;
  transform: none;
}

/* The name, with play at its right: the panel is right-aligned, so the button stays put at the right edge
   (under the bird) while names of any length grow leftwards. */
.hearing__title {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 2px;
}

.hearing__name {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
}

.hearing__sub,
.hearing__line {
  margin: 1px 0 0;
}

/* An imagined bird's other name: upright, on its own line, set apart from the italic Latin below it. */
.hearing__aka {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
}

.hearing__aka-label {
  margin-right: 4px;
  color: var(--ink-quiet);
}

.hearing__aka-name {
  position: relative;
  text-decoration: underline dotted var(--ink-quiet);
  text-underline-offset: 3px;
  cursor: help;
  outline: none;
}

/* Why it has a real bird's name: a card above it, in the Keys panel's surface. */
.hearing__aka-card {
  position: absolute;
  z-index: 6;
  right: 0;
  bottom: calc(100% + 8px);
  display: block;
  width: 240px;
  padding: 10px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  text-align: left;
  text-decoration: none;
  white-space: normal;
  color: var(--ink-quiet);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.hearing__aka-name:hover .hearing__aka-card,
.hearing__aka-name:focus-visible .hearing__aka-card {
  opacity: 1;
}


.hearing__sound {
  margin-top: 6px;
  color: var(--ink);
}

.hearing__swatch {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 5px 1px 0;
  border-radius: 50%;
}

.hearing__source {
  margin: 6px 0 0;
  font-size: 11px;
}

.hearing__source + .hearing__source {
  margin-top: 1px;
}

.hearing__meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hearing__meta + .hearing__meta {
  margin-left: 10px;
}

.hearing__meta svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hearing a {
  color: inherit;
}

.hearing .meter {
  justify-content: flex-end;
  width: 200px;
  margin-left: auto;
}

/* The bird, with its measurements shown only while the pointer is over it. */
.hearing__figure {
  position: relative;
}

.hearing__bird {
  display: block;
  width: 180px;
  height: 120px;
  margin: 0 0 4px auto;
}

.hearing__bird[hidden] {
  display: none;
}

.hearing__body {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.hearing__figure:hover .hearing__body {
  opacity: 1;
  pointer-events: auto; /* so the source can be followed */
}

/* Options: a drawer under the header, closed by default. */
.dock__label {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-quiet);
}

.options {
  position: fixed;
  z-index: 4;
  top: 56px;
  left: var(--gutter);
  width: 320px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 4px 16px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
}

.options[hidden] {
  display: none;
}

.options section {
  padding: 10px 0;
  border-top: 1px solid var(--rule);
}

.options section:first-child {
  border-top: 0;
}

.options .select,
.options select {
  background: var(--bg);
  color: var(--ink);
}

.options .select {
  width: 100%;
}

.experience .map-tip {
  position: fixed;
  z-index: 6;
  max-width: 228px;
  padding: 6px 9px;
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-quiet);
  pointer-events: none;
}

.experience .map-tip b {
  color: var(--ink);
  font-weight: 500;
}

.experience .map-tip[hidden] {
  display: none;
}

/* Phones. One row of controls under the header (the map caption left, the actions right, the legend beneath), a
   small second view below it at the right, the main view filling the rest, and what you hear in a sheet at the
   bottom. Type steps: 11 (quiet details), 12 (text), 13 (the nav), 17 (the name). */
@media (max-width: 640px) {
  :root {
    --inset-w: 38vw;
    --inset-h: 20vh;
  }

  /* The small view sits bottom right, where the thumb is, under the side rail; dragging it moves you. */
  body:not(.map-main) #map-stage,
  .map-main #form-stage {
    top: auto;
    bottom: calc(8px + env(safe-area-inset-bottom));
    right: 4px;
    width: var(--inset-w);
    height: var(--inset-h);
  }

  /* The caption's dropdowns and the keys give way to the side rail and the Layers sheet. */
  .map-settings,
  .keys,
  .keys__more,
  .keys__panel {
    display: none;
  }

  /* What you hear: at the top left over the space, as a map labels a place, with no card behind it: the bird,
     recorded or imagined, the name with play beside it, the Latin name, then the quieter lines (the blend, the
     place, the credit). */
  .hearing {
    top: 52px;
    left: 0;
    right: 0;
    bottom: auto;
    display: grid;
    grid-template-columns: 1fr auto auto; /* state, name, Latin | the bird | play: the text keeps one left edge */
    column-gap: 12px;
    align-items: center;
    max-width: none;
    padding: 4px 16px 0;
    background: none;
    border: 0;
    text-align: left;
  }

  .hearing > * {
    grid-column: 1 / -1;
  }

  .hearing > .hearing__figure {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .hearing > .hearing__state-row,
  .hearing > .hearing__state {
    grid-column: 1;
    grid-row: 1;
  }

  /* Play takes its own column beside the text, so the name and its Latin name sit together. */
  .hearing > .hearing__title {
    display: contents;
  }

  .hearing__title > .hearing__name {
    grid-column: 1;
    grid-row: 2;
  }

  .hearing__title > .hearing__play {
    grid-column: 3;
    grid-row: 1 / span 3;
    align-self: center;
  }

  .hearing > .hearing__sub {
    grid-column: 1;
    grid-row: 3;
    margin-top: 0;
  }

  /* The quieter lines under it: one each, cut short rather than wrapping. */
  .hearing > .hearing__line,
  .hearing > .hearing__source {
    margin-top: 4px;
    overflow: hidden;
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* Except the loading watchdog's (js/load-watch.js): its error has to be read whole. */
  .hearing > .hearing__line.load-watch {
    white-space: normal;
  }

  .hearing > .hearing__line:empty,
  .hearing > .hearing__source:empty {
    display: none;
  }

  .hearing__figure .hearing__bird {
    width: 56px;
    height: 42px;
    margin: 0;
  }

  .hearing__body {
    display: none;
  }

  .hearing__name {
    font-size: 17px;
  }

  .options {
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
  }
}

/* Touch screens: the keycaps are what you hold to fly, so make them finger-sized. */
@media (pointer: coarse) {
  .keys__status {
    display: none; /* the first-visit hint names the gestures; this line would run into Now hearing */
  }

  .keys__caps {
    grid-template-columns: repeat(4, 48px);
    gap: 6px;
  }

  .keys__caps kbd {
    height: 48px;
    font-size: 14px;
  }

  .hearing__play {
    width: 48px;
    height: 48px;
    font-size: 14px;
  }
}

/* The first time on a touch screen: how the fingers move you. */
.touch-hint {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: 40%;
  max-width: min(320px, calc(100vw - 48px));
  margin: 0;
  padding: 10px 14px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--ink);
  pointer-events: none;
  transition: opacity 0.4s;
}

.touch-hint.is-gone {
  opacity: 0;
}

/* On a tablet the Keys list opens from the nav bar. */
.keys__panel.keys__panel--nav {
  position: fixed;
  top: 56px;
  left: var(--gutter);
  bottom: auto;
}

/* Phones: Search (go to a species), Tour and Layers as a rail of round buttons on the right, above the small
   view, in reach of the thumb; menus open to the left. */
.side-rail {
  position: fixed;
  z-index: 6;
  right: 12px;
  bottom: calc(var(--inset-h) + 16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.side-rail__layers svg .line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.side-rail .keys__row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.side-rail .action,
.side-rail .dropdown__button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  text-shadow: none;
}

.side-rail .action[data-label]::after {
  content: none; /* the key hints ([ ] T): no keyboard here */
}

/* Each button's name, in a small label to its left: on hover, on keyboard focus, and for a moment after a tap. */
.side-rail [data-tip] {
  position: relative;
}

.side-rail [data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.side-rail [data-tip]:focus-visible::before,
.side-rail [data-tip].is-tipped::before {
  opacity: 1;
}

@media (hover: hover) {
  .side-rail [data-tip]:hover::before {
    opacity: 1;
  }
}

.side-rail .icon-button,
.side-rail .dropdown__button--icon {
  width: 44px;
  padding: 0;
}

.side-rail svg {
  width: 18px;
  height: 18px;
}

.side-rail .action[hidden],
.side-rail .dropdown[hidden],
.side-rail .keys__more,
.side-rail #wander {
  display: none; /* somewhere new stays a key (N) and a desktop button */
}

.side-rail .dropdown {
  position: relative;
}

/* The phone's chrome, one system: sheets, menus and cards are square, with a thin rule, as the header's menus are;
   the choices in them are square cells joined edge to edge, each group one unit, the chosen cell filled in ink. Only
   the floating map controls (the rail, Play) are round. */

/* The rail's menus open as sheets across the screen, headed like Layers (sheet-head): the tours from the bottom, as
   Layers does; the species search from under the bar, so its field stays above the keyboard. */
.rail-sheet {
  position: fixed;
  z-index: 22;
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  width: auto;
  max-width: none;
  max-height: 70vh;
  overflow-y: auto;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  transform: none;
  background: var(--bg);
  border: 0;
  border-top: 1px solid var(--rule);
  backdrop-filter: none; /* solid */
}


.rail-sheet--search {
  top: 52px;
  bottom: auto;
  max-height: 55vh; /* above the keyboard */
  padding-bottom: 16px;
  border-top: 0;
  border-bottom: 1px solid var(--rule);
}

.rail-sheet .dropdown__note {
  display: none; /* each choice carries its own description */
}

.rail-sheet .dropdown__filter {
  width: 100%;
  min-height: 44px;
  margin: 0 0 10px;
  border-radius: 0;
  font-size: 16px; /* 16 px or more, or iOS zooms in */
}

/* Rows: joined cells, one above the next. */
.rail-sheet .dropdown__list {
  padding: 1px 0 0;
}

.rail-sheet .dropdown__list li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  margin-top: -1px;
  padding: 10px 14px;
  border: 1px solid var(--rule);
  font-size: 15px;
  color: var(--ink);
}

.rail-sheet .dropdown__list li small {
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-quiet);
}

.rail-sheet .dropdown__list li[aria-selected="true"]::before {
  content: none; /* a tour is an action, not a setting: nothing stays chosen */
}

.rail-sheet .dropdown__list li:active {
  background: var(--hover);
}

.site-nav__layers svg .line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

/* The Layers sheet: slides up from the bottom, from the side rail's Layers button; a scrim behind closes it. */
.layers-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.25);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.layers-scrim.is-open {
  opacity: 1;
}

.layers-sheet {
  position: fixed;
  z-index: 21;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 80vh;
  overflow-y: auto;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.layers-sheet.is-open {
  transform: none;
}

/* A sheet's head (Layers, Tour, Search): its name, and Done at the right, finger-sized. */
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}

.sheet-head .action {
  min-height: 44px;
  padding: 0 4px;
  margin-right: -4px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14px;
}

/* Each group one unit: square cells joined edge to edge, filling their rows, the chosen one filled in ink. */
.layers-sheet__group {
  padding: 14px 0 0;
}

.layers-sheet h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-quiet);
}

.layers-sheet__choices {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 1px 0 0 1px; /* room for the cells' overlapping borders */
  list-style: none;
}

.layers-sheet__choices li {
  flex: 1 0 auto;
  display: flex;
  margin: -1px 0 0 -1px;
}

.layers-sheet__choices button {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.layers-sheet__choices button[aria-pressed="true"] {
  position: relative; /* its border over its neighbours' */
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

/* How the joysticks work, under their choice; Show me brings back the card. */
.layers-sheet__note {
  margin: 8px 0 0;
  max-width: 46ch;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-quiet);
}

.layers-sheet__note .link-button {
  padding: 10px 0;
  margin: -10px 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* The card the first time the joysticks come on: centred over the space, until Got it. */
.sticks-help {
  position: fixed;
  z-index: 23;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 32px));
  padding: 18px 18px 14px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.sticks-help[hidden] {
  display: none;
}

.sticks-help h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.sticks-help p {
  margin: 0 0 8px;
  color: var(--ink-quiet);
}

.sticks-help .action {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
}

.layers-sheet .map-legend__items {
  margin-top: 4px;
  max-height: none;
  font-size: 11px;
  color: var(--ink-quiet);
}

.map-legend__items[hidden] {
  display: none; /* long legends (species, families) are left out: the space names them itself */
}

/* The joystick (steer.js): three axes under the finger, the chosen one in ink, a knob where the finger is. */
.steer {
  position: fixed;
  z-index: 8;
  pointer-events: none;
  animation: steer-in 0.2s ease-out;
}

.steer[hidden] {
  display: none;
}

.steer {
  /* the view widget's tints (view-gizmo.js), a little stronger over the busy space */
  --axis-x: color-mix(in oklab, #e5484d 70%, var(--ink-quiet));
  --axis-y: color-mix(in oklab, #30a46c 70%, var(--ink-quiet));
  --axis-z: color-mix(in oklab, #3e83f8 70%, var(--ink-quiet));
}

.steer__axis {
  stroke-width: 1;
  stroke-linecap: round;
  opacity: 0.55;
}

.steer__axis[data-axis="x"] { stroke: var(--axis-x); }
.steer__axis[data-axis="y"] { stroke: var(--axis-y); }
.steer__axis[data-axis="z"] { stroke: var(--axis-z); }

.steer__axis.is-active {
  stroke-width: 2;
  opacity: 1;
}

.steer__mark[data-axis="x"] { fill: var(--axis-x); }
.steer__mark[data-axis="y"] { fill: var(--axis-y); }
.steer__mark[data-axis="z"] { fill: var(--axis-z); }

.steer__mark.is-negative {
  fill: var(--bg);
  stroke: var(--ink-quiet);
  stroke-width: 1;
}

.steer__label {
  font: 11px var(--font);
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  opacity: 0.75;
}

.steer__label[data-axis="x"] { fill: var(--axis-x); }
.steer__label[data-axis="y"] { fill: var(--axis-y); }
.steer__label[data-axis="z"] { fill: var(--axis-z); }

.steer__label.is-active {
  opacity: 1;
}

.steer__centre {
  fill: none;
  stroke: var(--ink-quiet);
  stroke-width: 1;
  opacity: 0.5;
}

.steer__centre.is-free {
  animation: steer-free 0.35s ease-out;
}

@keyframes steer-free {
  from { stroke: var(--ink); stroke-width: 6; opacity: 1; }
  to { stroke-width: 1; opacity: 0.5; }
}

.steer__knob {
  fill: var(--ink-quiet); /* neutral at the centre; the locked axis's colour once one is chosen */
  stroke: var(--bg);
  stroke-width: 1.5;
}

.steer--x .steer__knob { fill: var(--axis-x); }
.steer--y .steer__knob { fill: var(--axis-y); }
.steer--z .steer__knob { fill: var(--axis-z); }

@keyframes steer-in {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* Phones: no blur over the moving 3-D (costly on a phone's GPU); the sheets are opaque instead. */
@media (max-width: 640px) {
  .hearing,
  .touch-hint,
  .options,
  .map-tip,
  .site-nav__menu {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg);
  }
}

/* ?perf=1: where the time goes, top left over everything. */
.perf-panel {
  position: fixed;
  z-index: 50;
  top: 44px;
  left: 8px;
  margin: 0;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #9f9;
  font: 10px/1.35 ui-monospace, Menlo, monospace;
  pointer-events: none;
}
.perf-panel pre { margin: 0; font: inherit; }
.perf-panel { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.perf-panel__switches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; pointer-events: auto; }
.perf-panel__switches button {
  padding: 6px 10px;
  border: 1px solid #9f9;
  border-radius: 4px;
  background: transparent;
  color: #9f9;
  font: inherit;
  font-size: 12px;
}
.perf-panel__switches button.is-off { border-color: #f99; color: #f99; text-decoration: line-through; }

/* Bird and Song: fingers move the space, never the page. A pinch or double tap that lands on text or a button
   would otherwise zoom the whole page (Safari ignores maximum-scale; stage.js also stops its gesture events). */
body.experience {
  touch-action: pan-x pan-y;
}

/* The species search's field, above its list. 16px so Safari doesn't zoom in when it gets focus. */
.dropdown__filter {
  display: block;
  width: calc(100% - 24px);
  margin: 4px 12px 6px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.dropdown__list li[hidden] {
  display: none;
}

/* Touch screens: a long press steers (steer.js), so it mustn't also select the page or open Safari's menu. */
@media (pointer: coarse) {
  body.experience {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  body.experience input {
    -webkit-user-select: text;
    user-select: text;
  }
}

/* Fly (twin-stick.js): a layer over the main view takes the thumbs; the small view, the details, the nav and the rail
   stay above it. Each stick is drawn only while a thumb is on it. */
.fly-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  touch-action: none;
}

.fly-layer[hidden] {
  display: none;
}

body.fly-on:not(.map-main) #map-stage,
body.fly-on.map-main #form-stage {
  z-index: 2;
}

.fly-stick {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border: 1.5px solid color-mix(in oklab, var(--ink) 35%, transparent);
  border-radius: 50%;
  background: color-mix(in oklab, var(--bg) 35%, transparent);
  pointer-events: none;
}

.fly-stick__knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: var(--imagined);
  border: 2px solid var(--bg);
}

.fly-stick.is-zooming {
  background: color-mix(in oklab, var(--imagined) 30%, transparent);
  transition: background 0.2s;
}

/* The view widget (view-gizmo.js): top left under the header on a computer, in the page's quiet ink. */
.view-gizmo {
  position: fixed;
  z-index: 6;
  top: 64px;
  left: calc(var(--gutter) - 8px);
  width: 92px;
  height: 92px;
  border: 1px solid transparent;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  transition: border-color 0.2s;
}

.view-gizmo:hover {
  border-color: var(--rule);
}

.view-gizmo:active {
  cursor: grabbing;
}

.view-gizmo--x { --axis: color-mix(in oklab, #e5484d 55%, var(--ink-quiet)); }
.view-gizmo--y { --axis: color-mix(in oklab, #30a46c 55%, var(--ink-quiet)); }
.view-gizmo--z { --axis: color-mix(in oklab, #3e83f8 55%, var(--ink-quiet)); }

.view-gizmo__line {
  stroke: var(--axis);
  stroke-width: 1;
  stroke-linecap: round;
}

.view-gizmo__mark {
  fill: var(--axis);
}

.view-gizmo__mark.is-negative {
  fill: var(--bg);
  stroke: var(--ink-quiet);
  stroke-width: 1;
}

.view-gizmo__label {
  fill: var(--axis);
  font: 11px var(--font);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.view-gizmo__hit {
  fill: transparent;
  cursor: pointer;
}

.view-gizmo__hit:hover {
  fill: color-mix(in oklab, var(--ink) 6%, transparent);
}

@media (max-width: 640px) {
  .view-gizmo {
    display: none; /* computers only: on a phone it would duplicate two-finger turning (docs/phone-interface.md) */
  }
}

/* Tracing back (O): the recordings behind what you hear, under Now hearing (js/provenance.js). */
.trace {
  margin: 6px 0 0;
  font-size: 11px;
}

.trace__toggle {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  cursor: pointer;
}

.trace__toggle::after {
  content: " ▸";
  color: var(--ink-quiet);
}

.trace__toggle.is-open::after {
  content: " ▾";
}

.trace__toggle:hover,
.trace__toggle:focus-visible {
  text-decoration-color: currentColor;
}

.trace__list {
  max-height: 40vh;
  margin: 6px 0 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.trace__item {
  display: grid;
  gap: 1px;
  padding: 4px 0;
  border-top: 1px solid var(--rule);
}

.trace__go {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  color: var(--ink);
  cursor: pointer;
}

.trace__go:hover .trace__who,
.trace__go:focus-visible .trace__who {
  text-decoration: underline;
}

.trace__share {
  font-variant-numeric: tabular-nums;
  color: var(--ink-quiet);
}

.trace__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px 8px;
}

.trace__note {
  margin: 4px 0 0;
  font-style: italic;
}

/* Phones: Now hearing reads left to right at the top, so the list does too, and stays short over the space. */
@media (max-width: 640px) {
  .trace__go,
  .trace__meta {
    justify-content: flex-start;
  }

  .trace__list {
    max-height: 30vh;
    background: var(--bg);
  }
}

/* Move / Turn (look-mode.js): what gestures on the sound do, at the bottom left while it is the main view on a touch
   screen. Two square cells joined, an icon and a word each, the chosen one filled in ink, as Layers' choices are. */
.view-mode {
  position: fixed;
  z-index: 7;
  left: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
}

.view-mode[hidden] {
  display: none;
}

.view-mode button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.view-mode button + button {
  margin-left: -1px;
}

.view-mode button[aria-pressed="true"] {
  position: relative;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.view-mode svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
