@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap");

:root {
  --chime-size: 50px;
  --rect-w: 10px;
  --rect-h: 100px;
  --hook-height: 30px;
  --hook-slant: 30px;
  --hook-depth: 40px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  /* dvh so mobile browser bars don't push things off-screen */
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  font-family: "IBM Plex Mono", monospace;
  color: #fff;
  background: rgb(88, 85, 126);
  background: linear-gradient(
    0deg,
    rgba(88, 85, 126, 1) 0%,
    rgba(129, 128, 173, 1) 49%,
    rgba(242, 172, 222, 1) 100%
  );
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#chime-container {
  --bar-width: 550px;
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 0;
  /* lets fingers drag across chimes instead of scrolling */
  touch-action: none;
}

#hook {
  width: var(--bar-width);
  height: var(--hook-height);
  border-left: var(--hook-slant) solid transparent;
  border-right: var(--hook-slant) solid transparent;
  border-bottom: var(--hook-depth) solid #000;
  box-sizing: content-box;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.string {
  position: absolute;
  width: 2px;
  background-color: #555;
  pointer-events: none;
}

.chime {
  position: absolute;
  transition: transform 0.6s, background-color 0.2s;
  transform-style: preserve-3d;
  perspective: 1000px;
  cursor: pointer;
}

.chime img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s;
  pointer-events: none;
  -webkit-user-drag: none;
}

.chime.flip img {
  transform: rotateY(180deg);
}

.circle,
.flower,
.square {
  width: var(--chime-size);
  height: var(--chime-size);
}

.circle {
  border-radius: 50%;
  background-color: #000;
}

.square {
  background-color: #000;
}

.flower {
  background-color: transparent;
}

.rectangle {
  width: var(--rect-w);
  height: var(--rect-h);
  background-color: #000;
}

#visualization {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 200px;
  /* frosted glass so the gradient shows through */
  background-color: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.chime,
.string {
  z-index: 1;
}

#visualization canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#freq-text {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 14px;
  padding: 2px 6px;
  background-color: rgba(88, 85, 126, 0.55);
  border-radius: 3px;
}

#freq-text:empty {
  display: none;
}

#hint {
  position: absolute;
  left: 50%;
  bottom: 230px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 12px;
  max-width: calc(100% - 32px);
  font-size: 14px;
  text-align: center;
  text-wrap: balance;
  background-color: rgba(88, 85, 126, 0.45);
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.6s;
}

#hint.hidden {
  opacity: 0;
}

.hint-touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .hint-mouse {
    display: none;
  }
  .hint-touch {
    display: inline;
  }
}

#site-footer {
  flex: none;
  text-align: center;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  font-size: 14px;
}

#site-footer p {
  margin: 0;
}

#site-footer a {
  color: #fff;
  text-decoration: none;
}

#site-footer a:hover,
#site-footer a:focus-visible {
  color: pink;
}

/* mobile */
@media only screen and (max-width: 600px) {
  :root {
    --chime-size: 34px;
    --rect-w: 8px;
    --rect-h: 64px;
    --hook-height: 20px;
    --hook-slant: 20px;
    --hook-depth: 28px;
  }

  #hint {
    bottom: 138px;
    font-size: 13px;
  }

  #freq-text {
    font-size: 12px;
  }

  #site-footer {
    font-size: 12px;
  }
}

/* short landscape phones */
@media only screen and (max-height: 500px) and (orientation: landscape) {
  :root {
    --chime-size: 30px;
    --rect-w: 8px;
    --rect-h: 50px;
  }
}
