/* The observatory: one canvas the size of the window (observatory.js lays the frame out on it), a play hint that
   fades once the music runs, the chord heard and its degree at the bottom left (the whole harmony there while it is
   paused), the deck along the top and the credits under it. Each sits on the picture at the frame's scale, set from
   the layout (--hu, --hb, --du, --dt, --ct, --hint-y, --hs). A window held upright (body.tall) gives the harmony,
   the deck and the credits bands of their own below the picture, at a finger's size. */
@font-face { font-family: 'Bodoni Moda'; src: url('../fonts/bodoni-moda-latin-standard-italic.woff2') format('woff2-variations'); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('../fonts/newsreader-latin-standard-normal.woff2') format('woff2-variations'); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Newsreader'; src: url('../fonts/newsreader-latin-standard-italic.woff2') format('woff2-variations'); font-weight: 200 800; font-style: italic; font-display: swap; }

:root { --face: 'Newsreader', 'Apple Symbols', 'Segoe UI Symbol', serif; }   /* Newsreader has no ♭ or ♯ */
html, body { margin: 0; height: 100%; background: #04060d; overflow: hidden; }
.stage {
  position: absolute; left: 0; top: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden;
  touch-action: manipulation;                  /* a quick second tap pauses, it does not zoom */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#sky { position: absolute; left: 0; top: 0; display: block; width: 100%; height: 100%; cursor: pointer; }

.hint {
  position: absolute; left: 50%; top: var(--hint-y, 44%); transform: translate(-50%, -50%) scale(var(--hs, 1));   /* above the opening octaves, clear of their light */
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: none; border: 0; color: rgba(233, 237, 248, .85); cursor: pointer; font: italic 300 15px/1 var(--face);
  letter-spacing: .02em; transition: opacity .6s; pointer-events: none;
}
.hint svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: .9; stroke-linejoin: round; filter: drop-shadow(0 0 14px rgba(180, 200, 255, .5)); }
.hint span { opacity: .6; }
body.playing .hint, body.still .hint { opacity: 0; }
body.film .hint { --hs: 1.45; font-size: 16px; line-height: 1.3; }   /* a film's invitation, read on a phone over the moving sky */
body.film .hint span { opacity: .9; white-space: pre-line; text-align: center; text-shadow: 0 0 3px #04060d, 0 0 10px rgba(4, 6, 13, .9), 0 0 22px rgba(4, 6, 13, .8); }

/* At the bottom left, over the past and above the horizon's rungs: the chord heard, named, and its degree in the
   key, changing with the chords. Paused or stopped, the rest of the harmony joins them (.more) on a dusk of its own:
   where, the scale numbered by degree, the bass. The rows keep their places either way. */
.harmony {
  position: absolute; left: 0; bottom: var(--hb, 172px); padding: 22px 64px 16px 48px; min-width: 560px; isolation: isolate;
  transform: scale(var(--hu, 1)); transform-origin: 0 100%;
  color: rgba(233, 237, 248, .92); font: 300 26px/1.38 var(--face);
  text-shadow: 0 0 2px rgba(4, 6, 13, .95), 0 0 8px rgba(4, 6, 13, .85), 0 0 16px rgba(4, 6, 13, .7);   /* legible over passing light */
  opacity: 0; transition: opacity .35s; pointer-events: none;
}
.harmony.ready { opacity: 1; }
.harmony::before {
  content: ''; position: absolute; z-index: -1; left: -60px; right: -110px; top: -90px; bottom: 0;
  background: radial-gradient(58% 70% at 36% 72%, rgba(4, 6, 13, .88) 40%, rgba(4, 6, 13, .55) 70%, rgba(4, 6, 13, 0) 100%);
  -webkit-mask-image: linear-gradient(#000 calc(100% - 28px), transparent); mask-image: linear-gradient(#000 calc(100% - 28px), transparent);
  transition: opacity .35s;
}
.harmony::after {                               /* as it plays: a band of dusk behind the chord and its degree only */
  content: ''; position: absolute; z-index: -1; left: 0; bottom: 20px; width: 760px; height: 150px;
  background: linear-gradient(to right, rgba(4, 6, 13, .6) 55%, rgba(4, 6, 13, 0));
  -webkit-mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent); mask-image: linear-gradient(transparent, #000 25%, #000 75%, transparent);
  transition: opacity .35s;
}
.harmony .more { transition: opacity .35s; }
body.film .harmony .more { display: none; }     /* a film shows the chord and its degree only: the sky gets their room */
body.playing .harmony .more, body.playing .harmony::before,
body.still .harmony .more, body.still .harmony::before, body:not(.playing):not(.still) .harmony::after { opacity: 0; }
.harmony p { margin: 0; display: flex; align-items: baseline; gap: 16px; white-space: nowrap; }
.harmony .where { display: block; margin-bottom: 4px; font: italic 300 20px var(--face); color: rgba(233, 237, 248, .5); }
.harmony .label { width: 82px; flex: none; font: italic 300 20px var(--face); color: rgba(233, 237, 248, .5); }
.harmony .value { font-style: italic; }
.harmony .numeral { font-size: 30px; }
.harmony sup { font-size: .62em; margin-left: 1px; }
.harmony .aside { font: italic 300 21px var(--face); color: rgba(233, 237, 248, .62); }
.harmony .names { display: inline-flex; gap: 11px; font-weight: 400; }
.harmony .names span { opacity: .5; }
.harmony .names span.lit { opacity: 1; font-weight: 500; }
.harmony p.scale { margin-top: 12px; }
.harmony .numbered span { position: relative; }
.harmony .numbered span::before {               /* each note's degree over it; the chord's root's the brightest */
  content: attr(data-degree); position: absolute; left: 0; right: 0; bottom: 84%; text-align: center;
  font: italic 300 14px var(--face); color: rgba(233, 237, 248, .62);
}
.harmony .numbered span.root::before { color: #fff; font-weight: 500; }
.harmony .numbered span.root { text-decoration-line: underline; text-decoration-thickness: 1.5px; text-underline-offset: 7px; }

/* The deck: stop, back a bar, play, forward a bar; the bar; the speed; the instrument. It sits along the top between
   the title and the wheel, and fades while the music plays and the pointer rests; a move brings it back. */
.deck {
  position: absolute; left: 50%; top: var(--dt, 40px); transform: translateX(-50%) scale(var(--du, 1)); transform-origin: 50% 0;
  display: flex; align-items: center; gap: 4px;
  color: rgba(233, 237, 248, .8); font: italic 300 21px/1 var(--face);
  transition: opacity .6s;
}
@media (hover: hover) { body.playing.idle:not(.tall) .deck, body.playing.idle:not(.tall) .credit { opacity: 0; } }
body.still .deck, body.still .credit { display: none; }
.deck button {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer;
  transition: color .2s, background-color .2s;
}
.deck button:hover { color: #fff; background: rgba(233, 237, 248, .08); }
.deck button:focus-visible, .deck select:focus-visible { outline: 1.5px solid rgba(233, 237, 248, .75); outline-offset: 2px; }
.deck svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; }
.deck .play { width: 56px; height: 56px; margin: 0 4px; box-shadow: inset 0 0 0 1px rgba(233, 237, 248, .34); }
.deck .play svg { width: 24px; height: 24px; }
.deck .when-playing, body.playing .deck .when-paused { display: none; }
body.playing .deck .when-playing { display: inline; }
.deck .bar { min-width: 76px; margin: 0 24px 0 10px; color: rgba(233, 237, 248, .56); font-variant-numeric: tabular-nums; white-space: nowrap; }
.deck .speed { display: flex; align-items: center; margin-right: 24px; }
.deck output { min-width: 54px; text-align: center; font-variant-numeric: tabular-nums; }
.deck select {
  appearance: none; -webkit-appearance: none; border: 0; border-radius: 0; cursor: pointer;
  border-bottom: 1px solid rgba(233, 237, 248, .26); color: inherit; font: inherit; padding: 9px 28px 9px 2px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6.5l4 4 4-4' fill='none' stroke='%23e9edf8' stroke-opacity='.7' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 4px center / 15px;
}
.deck select:hover { border-bottom-color: rgba(233, 237, 248, .6); }
.deck option, .deck optgroup { background: #0b0f1c; color: #e9edf8; font-style: normal; }
.deck .loading { min-width: 110px; padding-left: 12px; color: rgba(233, 237, 248, .5); font-size: 17px; white-space: nowrap; }
.hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.deck button:disabled { opacity: .3; cursor: default; background: none; }
.credit {
  position: absolute; left: 50%; top: var(--ct, 104px); transform: translateX(-50%) scale(var(--du, 1)); transform-origin: 50% 0;
  width: max-content; max-width: calc((100vw - 32px) / var(--du, 1)); margin: 0; text-align: center; text-wrap: balance;
  color: rgba(233, 237, 248, .42); font: italic 300 15px/1.35 var(--face); transition: opacity .6s, visibility .6s; pointer-events: none;
}
@media (hover: none) { body.playing:not(.tall) .credit { opacity: 0; visibility: hidden; } }   /* a finger on the sky must not find the link */
.credit a {                                     /* where the notes come from, a quiet note (the edition is in the public domain) */
  color: inherit; pointer-events: auto; text-decoration-line: none; text-underline-offset: 3px; transition: color .2s;
}
.credit a:hover, .credit a:focus-visible { color: rgba(233, 237, 248, .85); text-decoration-line: underline; text-decoration-color: rgba(233, 237, 248, .4); }
.credit a:focus-visible { outline: 1.5px solid rgba(233, 237, 248, .75); outline-offset: 2px; }

/* A small screen on its side: the deck keeps its buttons, not its bar count. */
@media (orientation: landscape) and (max-height: 520px) {
  .deck .bar, .deck .loading:empty { display: none; }
}

/* A window held upright: the picture above; below it the harmony, the line of the piece (drawn on the canvas), the
   deck in two rows (the buttons, then the speed and the instrument) and the credits, each in a band of its own. */
body.tall .harmony::after { display: none; }   /* nothing passes behind it here */
body.tall .deck {
  left: 0; right: 0; top: auto; bottom: var(--credit-h, 52px); transform: none;
  flex-wrap: wrap; justify-content: center; row-gap: 2px; padding: 4px 12px 2px; font-size: 18px;
}
body.tall .deck::before { content: ''; flex-basis: 100%; order: 1; }
body.tall .deck .speed, body.tall .deck .voice { order: 2; }
body.tall .deck .bar { min-width: 0; margin: 0 0 0 10px; }
body.tall .deck .speed { margin-right: 18px; }
body.tall .deck .loading { position: absolute; right: 12px; top: -22px; min-width: 0; padding: 0; font-size: 13px; }
body.tall .credit {
  left: 16px; right: 16px; top: auto; bottom: 0; width: auto; max-width: none; transform: none;
  padding-bottom: max(8px, env(safe-area-inset-bottom)); font-size: 12px; min-height: 4.05em;
}
