Back to Morse Tree
SOURCE / PINNED RELEASE

Made of little things.

Morse Tree

Release
52c388d28ec3…
Author-recorded commit
fd8192a198f7…
License
LICENSE
Author’s source reference
nostr://npub1eg5pfnws6tg6rtp33tugpppqtv5u05crmf983qp438cdycwzngys0gxzcs/wss%3A%2F%2Fgit.napplet.soy%2F/n-6ab5aa84ba1

Archive hash verified: 9d22ca7f5a712965…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

src/styles.css
/* Morse Tree: a sunny notebook. Coral dots go left, teal dashes go right,
   sunflower marks where you are. App-owned colors; the host theme is not followed. */
:root {
  color-scheme: light;
  --paper: #fff6e4;
  --paper-line: #f1e2c4;
  --ink: #2b2340;
  --ink-soft: #7a6f8f;
  --dit: #ff6b5a;
  --dit-deep: #d9483a;
  --dah: #1fb5a8;
  --dah-deep: #138a80;
  --sun: #ffc83d;
  --sun-deep: #f29f05;
  --card: #ffffff;
  --grape: #8b6cff;
  --font: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Varela Round', 'Trebuchet MS', system-ui, sans-serif;
  --key-h: clamp(44px, 16vh, 84px);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  background-image: repeating-linear-gradient(0deg, transparent 0 27px, var(--paper-line) 27px 28px);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
.node:focus-visible {
  outline: 3px solid var(--grape);
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 1.4vh, 10px);
  padding: clamp(4px, 1.4vmin, 12px);
  padding-bottom: max(clamp(4px, 1.4vmin, 12px), env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- tape */

.tape {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.tape-paper {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
  padding: 0 10px;
  height: clamp(32px, 9vh, 52px);
  display: flex;
  align-items: center;
}

.tape-text {
  display: flex;
  align-items: center;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  white-space: pre;
  font-size: clamp(16px, 5vh, 30px);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.tape-text::-webkit-scrollbar {
  display: none;
}

.tape-char {
  display: inline-block;
  border-radius: 6px;
  padding: 0 1px;
  transition: background 120ms;
}

.tape-char.pop {
  animation: tape-pop 320ms cubic-bezier(0.3, 1.6, 0.5, 1);
}

.tape-char.playing {
  background: var(--sun);
}

.tape-caret {
  display: inline-block;
  width: 3px;
  height: 1em;
  margin-left: 2px;
  background: var(--dit);
  border-radius: 2px;
  animation: blink 1s steps(1) infinite;
  flex: none;
}

.tape-hint {
  margin-left: 8px;
  font-size: clamp(11px, 2.4vh, 15px);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-soft);
}

.tape-actions {
  display: flex;
  gap: 4px;
  flex: none;
}

/* ---------------------------------------------------------------- chips */

.chip {
  min-width: 40px;
  min-height: 40px;
  padding: 0 8px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--ink);
  font-size: 18px;
  line-height: 1;
  transition: transform 80ms, box-shadow 80ms, background 120ms;
}

.chip:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.chip:disabled {
  opacity: 0.35;
  cursor: default;
}

.chip.active {
  background: var(--sun);
}

.chip-text {
  font-weight: 800;
  font-size: 15px;
}

.chip-text::after {
  content: 'wpm';
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: var(--ink-soft);
}

/* ---------------------------------------------------------------- sea */

/* A cliff house and a boat, as in Ponyo: the boat's lamp flashes
   whatever is played, the house lamp flashes while you key. */
.sea {
  --lamp: #ffe46b;
  position: relative;
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  height: clamp(46px, 12vh, 100px);
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  /* Dusk, as when they signal in the film: the lamps need a dark sky to read. */
  background: linear-gradient(180deg, #27306a 0%, #5a4f8f 34%, #f0a17c 60%, #2f6fa3 60%, #1f4e7c 100%);
}

.sea svg {
  height: 100%;
  width: auto;
  flex: none;
  overflow: visible;
}

.waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18%;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 12px -7px, transparent 12px, rgba(255, 255, 255, 0.7) 12.5px 14.5px, #23598a 15px) 0 0 / 24px 100% repeat-x;
  animation: waves 4s linear infinite;
}

.cliff {
  fill: #74c365;
  stroke: var(--ink);
  stroke-width: 2;
}

.wall,
.cabin {
  fill: #fffdf6;
  stroke: var(--ink);
  stroke-width: 1.6;
}

.roof {
  fill: var(--dit);
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.window {
  fill: #7cc8f0;
  stroke: var(--ink);
  stroke-width: 1;
}

.balcony {
  fill: #c98a4b;
  stroke: var(--ink);
  stroke-width: 1.2;
}

.rail {
  stroke-width: 1;
}

.door {
  fill: var(--sun-deep);
  stroke: var(--ink);
  stroke-width: 1;
}

.post,
.mast,
.rig {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rig {
  stroke-width: 0.8;
}

.hull {
  fill: #2f4f9e;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.lamp {
  fill: #5d5872;
  stroke: var(--ink);
  stroke-width: 1.4;
}

.glow,
.beam {
  fill: var(--lamp);
  opacity: 0;
}

.lit .lamp {
  fill: var(--lamp);
}

.lit .glow {
  opacity: 0.8;
}

.lit .beam {
  opacity: 0.45;
}

.boat-body {
  transform-box: view-box;
  transform-origin: 60px 70px;
  animation: bob 3.2s ease-in-out infinite;
}

/* The light quiz needs the boat: keep it on screen and say whose lamp to read. */
.light-quiz .sea {
  box-shadow: 0 0 0 3px var(--sun);
}

/* ---------------------------------------------------------------- stage */

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.tree {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.edge-under {
  stroke: var(--paper);
  stroke-width: 9;
  stroke-linecap: round;
}

.edge-line {
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.4;
  transition: opacity 150ms, stroke-width 150ms;
}

.edge-dit .edge-line {
  stroke: var(--dit);
  stroke-dasharray: 0.1 9;
  stroke-width: 6;
}

.edge-dah .edge-line {
  stroke: var(--dah);
  stroke-dasharray: 14 7;
}

.edge.lit .edge-line {
  opacity: 1;
  stroke-width: 7;
}

.edge-dit.lit .edge-line {
  stroke-width: 9;
}

/* Pointer target only. */
.node-hit {
  fill: transparent;
}

.node-body {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 160ms;
}

.node-disc {
  fill: var(--card);
  stroke: var(--ink);
  stroke-width: 2.5;
  transition: fill 150ms;
}

.node.has-letter {
  cursor: pointer;
}

.node.has-letter:hover .node-body {
  transform: scale(1.08);
}

.node-label {
  fill: var(--ink);
  font-weight: 800;
  pointer-events: none;
  transition: opacity 150ms;
}

.root .node-disc {
  fill: var(--ink);
}

.root-dot {
  fill: var(--sun);
}

.node.on-path .node-disc {
  fill: #fff0bf;
}

.node.current .node-disc {
  fill: var(--sun);
  stroke-width: 3.5;
}

.root.on-path .node-disc {
  fill: var(--ink);
}

/* The node the held key would reach if released now. */
.node.preview .node-disc {
  stroke: var(--grape);
  stroke-width: 4;
  stroke-dasharray: 4 3;
}

.node.preview-none .node-disc {
  stroke: var(--dit-deep);
  stroke-width: 4;
}

.node.pop .node-body {
  animation: node-pop 280ms cubic-bezier(0.3, 1.8, 0.5, 1);
}

.node.reveal .node-body {
  animation: node-pop 380ms cubic-bezier(0.3, 1.8, 0.5, 1);
}

.node.shake .node-body {
  animation: shake 420ms;
}

.legend {
  font-weight: 800;
  pointer-events: none;
}

.legend-dit {
  fill: var(--dit-deep);
}

.legend-dah {
  fill: var(--dah-deep);
}

.spark {
  fill: var(--sun);
  stroke: var(--ink);
  stroke-width: 2;
  pointer-events: none;
  transition-property: transform;
  transition-timing-function: linear;
  opacity: 0;
}

.spark.moving {
  opacity: 1;
}

.commit-ring {
  fill: none;
  stroke: var(--grape);
  stroke-width: 3.5;
  stroke-linecap: round;
  pointer-events: none;
  animation-name: drain;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.burst circle {
  animation: burst 800ms cubic-bezier(0.2, 0.8, 0.4, 1) forwards;
}

/* Small frames: no room for the tree, so show the keyed code and its letter. */
.compact {
  display: none;
}

.stage.is-compact .tree {
  display: none;
}

.stage.is-compact .compact {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.compact-letter {
  font-size: clamp(22px, 18vh, 56px);
  font-weight: 900;
  line-height: 1;
  color: var(--ink);
}

.compact-code {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-soft);
}

.banner {
  flex: none;
  align-self: center;
  max-width: 100%;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 2px solid transparent;
  border-radius: 999px;
  font-size: clamp(12px, 2.4vh, 16px);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}

.banner > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.banner-info {
  background: var(--card);
}

.banner-ok {
  background: #d9fbe9;
}

.banner-warn {
  background: #ffe1dc;
}

.banner-quiz {
  background: #ece6ff;
}

.banner-replay {
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  padding: 0 10px;
  height: 26px;
  font-weight: 800;
}

/* ---------------------------------------------------------------- keys */

.keys {
  display: flex;
  align-items: stretch;
  gap: clamp(4px, 1.5vw, 12px);
  flex: none;
}

.key {
  flex: 1;
  min-height: 44px;
  height: var(--key-h);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: clamp(3px, 1vh, 8px);
  padding: 0 clamp(10px, 3vw, 22px);
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform 50ms, box-shadow 50ms, background 80ms;
}

.key.down {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
  background: #3d3358;
}

/* Labels sit over the two halves of the meter below. */
.key-label {
  display: flex;
  font-size: clamp(13px, 3.4vh, 20px);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.key-label > span {
  flex: 1;
  text-align: center;
  opacity: 0.55;
  transition: opacity 80ms, color 80ms;
}

.key.down:not(.is-dah) .key-dit {
  opacity: 1;
  color: var(--dit);
}

.key.down.is-dah .key-dah {
  opacity: 1;
  color: var(--dah);
}

/* Press length from 0 to 4 units: dot below the midpoint at 2, dash above. */
.meter {
  position: relative;
  height: clamp(8px, 2.4vh, 14px);
  border-radius: 999px;
  background: linear-gradient(90deg, rgb(255 107 90 / 0.25) 0 50%, rgb(31 181 168 / 0.25) 50% 100%);
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--dit);
  border-radius: 999px;
}

.key.is-dah .meter-fill {
  background: var(--dah);
}

.meter-fill.fade {
  transition: opacity 900ms 300ms;
  opacity: 0.35;
}

.meter-split {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  margin-left: -1.5px;
  background: #fff;
}

/* Ideal lengths: one unit for a dot, three for a dash. */
.meter-ideal {
  position: absolute;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.8;
}

.ideal-dit {
  left: 25%;
}

.ideal-dah {
  left: 75%;
}

/* ---------------------------------------------------------------- timing */

.timing {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: clamp(30px, 8vh, 48px);
}

.rhythm {
  flex: none;
  min-width: 92px;
  padding: 4px 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  color: var(--ink-soft);
}

.rhythm.good {
  background: #d9fbe9;
  color: var(--ink);
}

.rhythm.fair {
  background: #fff0bf;
  color: var(--ink);
}

.rhythm.poor {
  background: #ffe1dc;
  color: var(--ink);
}

.strip {
  flex: 1;
  min-width: 0;
  height: 100%;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.strip-ideal {
  fill: none;
  stroke-width: 1.5;
  stroke-dasharray: 3 2;
}

.strip-ideal.dit {
  stroke: var(--dit-deep);
}

.strip-ideal.dah {
  stroke: var(--dah-deep);
}

.strip-mark.dit {
  fill: var(--dit);
}

.strip-mark.dah {
  fill: var(--dah);
}

.strip-mark.fair {
  opacity: 0.75;
}

.strip-mark.poor {
  opacity: 0.45;
}

.strip-char {
  fill: var(--ink);
  font-weight: 900;
}

.strip-word,
.strip-pause {
  stroke: var(--ink-soft);
  stroke-width: 2;
  stroke-linecap: round;
}

.strip-pause {
  stroke-dasharray: 2 3;
}

.tools {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 4px;
  align-content: center;
}

/* Narrow frames stack the options above the two big keys. */
@media (max-width: 520px) {
  .keys {
    flex-wrap: wrap;
  }

  .tools {
    order: -1;
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-height: 260px) {
  .banner {
    height: 26px;
  }

  .tape-hint,
  .key-label,
  .timing,
  .sea,
  #lightQuizToggle {
    display: none;
  }

  .chip {
    min-height: 32px;
    min-width: 32px;
    font-size: 15px;
  }

  .chip-text::after {
    display: none;
  }
}

@media (max-height: 260px) and (max-width: 520px) {
  .tools {
    display: none;
  }
}

/* ---------------------------------------------------------------- motion */

@keyframes waves {
  to {
    background-position: 24px 0;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1.5deg);
  }
  50% {
    transform: translateY(2px) rotate(1.5deg);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes tape-pop {
  0% {
    transform: translateY(-14px) scale(1.6);
    color: var(--dit);
  }
  100% {
    transform: none;
  }
}

@keyframes node-pop {
  40% {
    transform: scale(1.28);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-5px) rotate(-6deg);
  }
  40%,
  80% {
    transform: translateX(5px) rotate(6deg);
  }
}

@keyframes drain {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: var(--circ);
  }
}

@keyframes burst {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(var(--dx), var(--dy)) scale(0.3);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }

  .spark {
    transition-duration: 0ms !important;
  }

  .commit-ring {
    display: none;
  }
}