/* SoundEscape — a cyanotype listening chart.
   The field is the exposed emulsion (Prussian blue, pale ink); the key is the
   unexposed paper margin (paper white, Prussian ink). One warm accent: the sun,
   for "you" and for what's live. */

:root {
  --field-hi: #22508f;
  --field: #183f7d;
  --field-lo: #0c2756;
  --on-field: #eaf1fb;
  --on-field-2: #bccde9;
  --on-field-3: rgba(234, 241, 251, 0.56);
  --chart: rgba(234, 241, 251, 0.2);
  --chart-strong: rgba(234, 241, 251, 0.42);
  --sun: #ffc94d;

  --paper: #eef1f2;
  --paper-2: #e2e8eb;
  --ink: #11316a;
  --ink-2: #435f8e;
  --rule: rgba(17, 49, 106, 0.13);
  --rule-strong: rgba(17, 49, 106, 0.32);

  --sans: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "Martian Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --key-w: 392px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1a31;
    --paper-2: #16253f;
    --ink: #e4ecf8;
    --ink-2: #a8bad7;
    --rule: rgba(228, 236, 248, 0.1);
    --rule-strong: rgba(228, 236, 248, 0.26);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 var(--sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font: inherit; color: inherit; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--key-w);
  height: 100vh;
  height: 100svh;
}

/* ------------------------------------------------------------------ field */

.field {
  position: relative;
  overflow: hidden;
  color: var(--on-field);
  background-color: var(--field);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='720' height='720'%3E%3Cfilter id='m' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.0042 0.0058' numOctaves='4' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.03 0 0 0 0 0.1 0 0 0 0 0.27 2.4 0 0 0 -0.95'/%3E%3C/filter%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' seed='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.92 0 0 0 0 0.95 0 0 0 0 1 0 0 0 1.6 -0.92'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3Crect width='100%25' height='100%25' filter='url(%23g)' opacity='0.22'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 70% 68% at 50% 50%, var(--field-hi) 0%, var(--field) 52%, var(--field-lo) 100%);
  background-size: 720px 720px, 100% 100%;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.field__air,
.field__chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.field__chart { pointer-events: none; overflow: visible; }

.field__sources { position: absolute; inset: 0; }

.chart__axis { fill: none; stroke: var(--chart); stroke-width: 1; stroke-dasharray: 1 6; }
.chart__ring { fill: none; stroke: rgba(234, 241, 251, 0.15); stroke-width: 1; }
.chart__core { fill: rgba(234, 241, 251, 0.05); stroke: var(--chart); stroke-width: 1; stroke-dasharray: 2 4; }
.chart__edge { fill: none; stroke: var(--chart-strong); stroke-width: 1.25; }
.chart__ticks { fill: none; stroke: var(--chart-strong); stroke-width: 1; }
.chart__db {
  transition: opacity 0.25s;
  font: 400 10px/1 var(--num);
  fill: var(--on-field-2);
  paint-order: stroke;
  stroke: var(--field);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.chart__edge-label {
  font: 500 12px/1 var(--sans);
  letter-spacing: 0.02em;
  fill: var(--on-field-2);
}

.listener__icon { fill: var(--sun); }
.listener__lr { font: 500 9.5px/1 var(--num); fill: var(--sun); text-anchor: middle; }

.field__hint {
  position: absolute;
  left: 50%;
  top: calc(50% + 40px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 82%;
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  color: var(--on-field);
  text-shadow: 0 0 6px var(--field), 0 0 2px var(--field);
  pointer-events: none;
}

.field__hint { transition: opacity 0.6s var(--ease); }
.app:not(.is-empty) .field__hint { opacity: 0; }

.field__brand { display: none; }

.field__edge {
  position: absolute;
  top: 0;
  right: 0;
  width: 40px;
  height: 100%;
  pointer-events: none;
}
.edge__paper { fill: var(--paper); }

/* sound marks ------------------------------------------------------------ */

.src {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.src__dot {
  position: absolute;
  left: -21px;
  top: -21px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--field);
  border: 1.25px dashed rgba(234, 241, 251, 0.5);
  color: rgba(234, 241, 251, 0.78);
  transition:
    background-color 0.35s var(--ease),
    color 0.35s var(--ease),
    border-color 0.35s var(--ease),
    box-shadow 0.35s var(--ease),
    scale 0.3s var(--ease);
}

.src__dot .glyph { width: 22px; height: 22px; }

.src__spin {
  position: absolute;
  inset: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  opacity: 0;
  pointer-events: none;
}
.src__spin circle {
  fill: none;
  stroke: var(--sun);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 22 108;
}

.src__label {
  position: absolute;
  left: 0;
  top: 27px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 2px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 5px var(--field), 0 0 2px var(--field);
}
.src__name {
  font-size: 13px;
  font-weight: 560;
  line-height: 1.15;
  color: var(--on-field-2);
  transition: color 0.3s;
}
.src__short { display: none; }
.src__level {
  font: 500 10.5px/1.2 var(--num);
  color: var(--on-field);
  min-height: 1.2em;
}
.src__level:empty { display: none; }

@media (hover: hover) {
  .src:hover .src__dot { border-color: var(--on-field); color: var(--on-field); }
  .src:hover .src__name { color: var(--on-field); }
}

.src.label-up .src__label { top: auto; bottom: 27px; }

.src.is-in .src__dot {
  background: var(--on-field);
  border: 1.25px solid var(--on-field);
  color: var(--field);
  box-shadow: 0 8px 20px -8px rgba(3, 14, 38, 0.75);
}
.src.is-in .src__name { color: var(--on-field); font-weight: 650; }
@media (hover: hover) {
  .src.is-in:hover .src__dot { scale: 1.06; }
}

.src.is-held { cursor: grabbing; z-index: 3; }
.src.is-held .src__dot { scale: 1.12; box-shadow: 0 14px 28px -10px rgba(3, 14, 38, 0.8); }

.src.is-loading .src__spin { opacity: 1; animation: spin 1.1s linear infinite; }
.src.is-error .src__dot {
  background: var(--field);
  border: 1.5px solid var(--on-field);
  color: var(--on-field);
}
.src.is-error .src__level { color: var(--on-field); font-family: var(--sans); font-size: 11.5px; }

.src:focus { outline: none; }
.src:focus-visible .src__dot { outline: 2px solid var(--sun); outline-offset: 4px; }

.is-dragging, .is-dragging * { cursor: grabbing !important; }

@keyframes spin { to { rotate: 360deg; } }

/* -------------------------------------------------------------------- key */

.key {
  position: relative;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-strong) transparent;
  --pad-top: 44px;
  padding: var(--pad-top) 36px 36px 26px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.07 0 0 0 0 0.19 0 0 0 0 0.42 0 0 0 1.4 -0.9'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.35'/%3E%3C/svg%3E");
}

.wordmark {
  margin: 0;
  font-size: 46px;
  line-height: 0.92;
  font-weight: 760;
  font-variation-settings: "wdth" 76;
  letter-spacing: -0.03em;
}

/* "Sound" light, "Escape" heavy: the capital E must read, or it's "soundscape". */
.brand__sound { font-weight: 360; letter-spacing: -0.02em; }

.lede {
  margin: 14px 0 0;
  max-width: 33ch;
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* transport */

.transport {
  position: sticky;
  top: calc(-1 * var(--pad-top)); /* sticky insets count from inside the key's padding */
  z-index: 4;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 20px 0;
  margin-block: -1px 0;
  border-block: 1px solid var(--rule);
  background: var(--paper);
}

.play {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 10px 22px -12px rgba(9, 28, 66, 0.8);
  transition: scale 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
@media (hover: hover) {
  .play:hover { scale: 1.04; }
}
.play:active { scale: 0.97; }
.play:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
.play__icon { width: 26px; height: 26px; fill: currentColor; }
.play__label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.play__bars { display: none; }
.is-playing .play__tri { display: none; }
.is-playing .play__bars { display: inline; }

.transport__meta { display: grid; gap: 8px; min-width: 0; }

.transport__status {
  margin: 0;
  font-size: 14px;
  font-weight: 560;
  line-height: 1.3;
  text-wrap: pretty;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.transport__status::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rule-strong);
  transform: translateY(-1px);
  transition: background 0.3s;
}
.is-playing:not(.is-empty) .transport__status::before {
  background: var(--sun);
  box-shadow: 0 0 0 3px rgba(255, 201, 77, 0.28);
}

.volume { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; }
.volume__label { font-size: 12px; color: var(--ink-2); }

/* range inputs: a hairline track filled in ink, a ring thumb */

.range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 24px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill), var(--rule-strong) var(--fill));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  transition: scale 0.15s;
}
.range:active::-webkit-slider-thumb { scale: 1.15; }
.range::-moz-range-track { height: 2px; border-radius: 2px; background: var(--rule-strong); }
.range::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--ink); }
.range::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
}
.range:focus { outline: none; }
.range:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 6px; }

/* option rows, set like a printed key: name, dotted leader, value */

.tools { display: grid; margin-top: -12px; }

.tool {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  text-align: left;
}
button.tool { cursor: pointer; }
.tool__name { font-size: 14px; font-weight: 520; }
.tool__left {
  font: 400 11px/1 var(--num);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.tool__value {
  margin-left: auto;
  font-size: 13.5px;
  font-weight: 560;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.tool:focus { outline: none; }
.tool:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; border-radius: 6px; }

.seg {
  margin-left: auto;
  display: inline-flex;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  overflow: hidden;
}
.seg__opt {
  min-width: 34px;
  padding: 5px 7px;
  border: 0;
  border-left: 1px solid var(--rule);
  background: none;
  font: 500 11.5px/1 var(--num);
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.seg__opt:first-child { border-left: 0; font-family: var(--sans); font-size: 12.5px; }
.seg__opt[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg__opt:focus { outline: none; }
.seg__opt:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }

.switch {
  margin-left: auto;
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  border: 1.5px solid var(--ink);
  transition: background-color 0.2s var(--ease);
}
.switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ink);
  transition: translate 0.25s var(--ease), background-color 0.2s;
}
.tool--drift[aria-checked="true"] .switch { background: var(--ink); }
.tool--drift[aria-checked="true"] .switch__knob { translate: 14px 0; background: var(--paper); }

@media (hover: hover) {
  button.tool:hover .tool__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
  .seg__opt:not([aria-pressed="true"]):hover { background: var(--paper-2); color: var(--ink); }
}

/* sound list */

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }

.section-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  font-variation-settings: "wdth" 84;
  letter-spacing: -0.015em;
}

.family { margin-top: 16px; }
.family__title {
  margin: 0 0 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}

.rows { list-style: none; margin: 0; padding: 0; }
.row { border-top: 1px solid var(--rule); }
.row:last-child { border-bottom: 1px solid var(--rule); }

.row__toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 8px 6px 8px 2px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.15s;
}
@media (hover: hover) {
  .row__toggle:hover { background: var(--paper-2); }
}
.row__toggle:focus { outline: none; }
.row__toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

.row__glyph {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px dashed var(--rule-strong);
  color: var(--ink-2);
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.row__glyph .glyph { width: 17px; height: 17px; }
.row__name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__state {
  font: 400 11px/1.2 var(--num);
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.row__state.is-words { font: 400 12.5px/1.2 var(--sans); }
.row.is-in .row__glyph { background: var(--ink); border: 1px solid var(--ink); color: var(--paper); }
.row.is-in .row__name { font-weight: 640; }
.row.is-in .row__state { color: var(--ink); }
.row.is-error .row__glyph { background: none; border: 1.5px solid var(--ink); color: var(--ink); }
.row.is-error .row__state { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }

.row__level {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 6px 10px 44px;
}
.row__level[hidden] { display: none; }
.row__far,
.row__near { font-size: 11.5px; color: var(--ink-2); }

/* starting points */

.clear {
  border: 0;
  background: none;
  padding: 4px 2px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-radius: 4px;
}
@media (hover: hover) {
  .clear:hover { color: var(--ink); }
}
.clear:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.is-empty .clear { visibility: hidden; }

.mixes__list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.mix {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 11px 12px 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}
@media (hover: hover) {
  .mix:hover { background: var(--paper-2); border-color: var(--ink); }
}
.mix:active { background: var(--paper-2); }
.mix:focus { outline: none; }
.mix:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mix__name { font-size: 14.5px; font-weight: 600; line-height: 1.2; }
.mix__glyphs { display: flex; gap: 4px; color: var(--ink-2); }
.mix__glyphs .glyph { width: 16px; height: 16px; }

/* footer */

.key__foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-2);
}
.key__foot p { margin: 0 0 8px; max-width: 46ch; }
.key__foot p:last-child { margin-bottom: 0; }
.key__foot strong { color: var(--ink); font-weight: 600; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 4px;
  margin-inline: 1px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font: 500 10.5px/1.4 var(--num);
  text-align: center;
  color: var(--ink);
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
}

/* --------------------------------------------------------------- compact */

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100svh;
  }

  .field { height: min(118vw, 66svh); min-height: 360px; }

  .field__edge { top: auto; bottom: 0; left: 0; width: 100%; height: 30px; }

  .field__brand {
    display: block;
    position: absolute;
    top: calc(14px + env(safe-area-inset-top, 0px));
    left: 18px;
    margin: 0;
    font-size: 22px;
    font-weight: 760;
    font-variation-settings: "wdth" 76;
    letter-spacing: -0.03em;
    color: var(--on-field);
  }

  .field__hint { top: calc(50% + 30px); font-size: 13px; }

  .src__dot { left: -18px; top: -18px; width: 36px; height: 36px; }
  .src__dot .glyph { width: 19px; height: 19px; }
  .src__label { top: 22px; }
  .src__name { font-size: 12px; }
  .src__full { display: none; }
  .src__short { display: inline; }
  .src:not(.is-in) .src__name { font-size: 11px; }
  .src.label-up .src__label { bottom: 22px; }

  .key {
    overflow: visible;
    padding: 18px 20px calc(118px + env(safe-area-inset-bottom, 0px));
    gap: 24px;
  }
  .wordmark { display: none; }
  .lede { margin-top: 0; font-size: 15px; }

  .transport {
    position: fixed;
    top: auto;
    margin: 0;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    gap: 14px;
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--paper);
    border-top: 1px solid var(--rule);
    border-bottom: 0;
    box-shadow: 0 -10px 30px -18px rgba(9, 28, 66, 0.55);
  }
  .play { width: 54px; height: 54px; }
  .play__icon { width: 22px; height: 22px; }
  .transport__status { font-size: 13.5px; }

  .tools { margin-top: 0; }
}

@media (max-width: 380px) {
  .mixes__list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
  .src.is-loading .src__spin { animation: none; stroke-dasharray: 4 6; }
}
