/* The ocarina page. Each button has its own colour, and it carries everywhere: the key,
   its line on every staff, and the ♪ sparks it sends into the sky. Keep these in step
   with BUTTONS in ocarina.js. */

.oc {
  --oc-l: #7CC4FF;
  --oc-r: #3DDC84;
  --oc-a: #FFC93C;
  --oc-y: #FF7EB6;
  --oc-x: #B07CFF;
  --oc-panel: rgba(7, 10, 24, 0.82);
}

/* ---------- Hero and the ocarina ---------- */

.oc-hero {
  padding-block: calc(var(--header-h) + clamp(2.5rem, 8vh, 5rem)) clamp(3rem, 8vh, 5rem);
}
.oc-hero-inner {
  display: grid;
  justify-items: center;
  text-align: center;
}

.oc-kicker {
  margin: 0 0 0.75rem;
  color: var(--gold-hi);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.oc-title {
  margin: 0;
  color: var(--star);
  font-size: clamp(3rem, 10vw, 6.5rem);
  font-weight: 850;
  font-variation-settings: "wdth" 62;
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow: 0 0 40px rgba(124, 196, 255, 0.35);
}

.oc-lede {
  max-width: 38rem;
  margin: 1.25rem 0 0;
  color: var(--text);
  font-size: clamp(1.0625rem, 1.6vw, 1.1875rem);
  text-wrap: pretty;
}
.oc-lede i { color: var(--star); }

.ocarina {
  width: 100%;
  max-width: 40rem;
  margin-top: clamp(2rem, 5vh, 3rem);
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(0.75rem, 3vw, 2rem) clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--oc-panel);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* Five keys, each a little higher than the last, like the notes they play. */
.oc-keys {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(0.35rem, 2vw, 1.25rem);
  padding-top: 0.5rem;
}

.oc-key {
  --size: clamp(44px, 14vw, 84px);
  position: relative;
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  margin: 0 0 calc(var(--i) * clamp(6px, 1.8vw, 13px));
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.oc-key:focus-visible { outline: none; }
.oc-key:focus-visible .oc-key-face { outline: 2px solid var(--focus); outline-offset: 5px; }

.oc-key-face {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--c) 40%, white) 0, var(--c) 45%, color-mix(in srgb, var(--c) 62%, #0B1020) 100%);
  color: #0B1020;
  font-size: calc(var(--size) * 0.36);
  font-weight: 850;
  font-variation-settings: "wdth" 112;
  line-height: 1;
  box-shadow:
    0 0 0 3px rgba(7, 10, 24, 0.9),
    0 0 0 4px color-mix(in srgb, var(--c) 45%, transparent),
    0 12px 28px -12px var(--c);
  transition: transform 0.35s var(--spring), box-shadow 0.25s ease, filter 0.2s ease;
}
/* A ring that ripples out when the key sounds. */
.oc-key-face::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--c);
  opacity: 0;
}
@media (hover: hover) {
  .oc-key:hover .oc-key-face { transform: translateY(-3px); filter: brightness(1.08); }
}
.oc-key.is-down .oc-key-face {
  transform: scale(0.9);
  filter: brightness(1.18);
  transition-duration: 0.08s;
  box-shadow:
    0 0 0 3px rgba(7, 10, 24, 0.9),
    0 0 0 5px var(--c),
    0 0 44px 6px color-mix(in srgb, var(--c) 70%, transparent);
}
.oc-key.is-down .oc-key-face::after { animation: oc-ripple 0.7s var(--ease-out); }
@keyframes oc-ripple {
  from { opacity: 0.9; transform: scale(1); }
  to { opacity: 0; transform: scale(1.7); }
}

.oc-key-note {
  color: var(--dust);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.oc-key.is-down .oc-key-note { color: var(--star); }

/* The half-step switches. */
.oc-mods {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.oc-mod {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(238, 242, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.25s ease;
}
.oc-mod span { font-size: 1.05em; font-weight: 800; }
.oc-mod:hover { border-color: rgba(238, 242, 255, 0.35); color: var(--star); }
.oc-mod.is-on {
  border-color: var(--gold-hi);
  background: rgba(245, 217, 168, 0.14);
  color: var(--star);
  box-shadow: 0 0 24px -6px rgba(245, 217, 168, 0.7);
}

.oc-help {
  margin: 1rem auto 0;
  max-width: 30rem;
  color: var(--dust);
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* "Your notes": the last few notes played, newest on the right. */
.oc-trail {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.staff.staff--trail {
  --pad: 20px; /* room for the ↑ ↓ badges, which the clipping would otherwise cut */
  padding-right: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  overflow: hidden;
  min-height: var(--staff-h);
  -webkit-mask-image: linear-gradient(to right, transparent, #000 22%);
  mask-image: linear-gradient(to right, transparent, #000 22%);
  /* An empty staff still shows its five lines. */
  background: var(--staff-lines);
}
.staff--trail .note { --b: 1; width: 34px; background: none; }
.staff--trail .note--new .note-dot { animation: oc-note-in 0.45s var(--spring); }
@keyframes oc-note-in {
  from { opacity: 0; transform: translateY(10px) scale(0.5); }
}
.oc-trail-status {
  margin: 0.5rem 0 0;
  min-height: 1.6em;
  color: var(--dust);
  font-size: 0.875rem;
}
.oc-trail-status a { color: var(--star); font-weight: 700; text-underline-offset: 0.2em; }
.oc-trail-status[data-found] { color: var(--gold-hi); font-weight: 650; }

/* ---------- Staffs ---------- */

/* One line per button, L at the bottom and X at the top, each tinted its button's colour.
   Every note slot draws its own piece of the lines, so a staff can wrap like text. */
.staff {
  --gap: 14px;
  --pad: 16px;
  --dot: 26px;
  --staff-h: calc(var(--pad) * 2 + var(--gap) * 4 + 1px);
  --staff-lines:
    linear-gradient(color-mix(in srgb, var(--oc-x) 40%, transparent), color-mix(in srgb, var(--oc-x) 40%, transparent)) 0 var(--pad) / 100% 1px no-repeat,
    linear-gradient(color-mix(in srgb, var(--oc-y) 40%, transparent), color-mix(in srgb, var(--oc-y) 40%, transparent)) 0 calc(var(--pad) + var(--gap)) / 100% 1px no-repeat,
    linear-gradient(color-mix(in srgb, var(--oc-a) 40%, transparent), color-mix(in srgb, var(--oc-a) 40%, transparent)) 0 calc(var(--pad) + var(--gap) * 2) / 100% 1px no-repeat,
    linear-gradient(color-mix(in srgb, var(--oc-r) 40%, transparent), color-mix(in srgb, var(--oc-r) 40%, transparent)) 0 calc(var(--pad) + var(--gap) * 3) / 100% 1px no-repeat,
    linear-gradient(color-mix(in srgb, var(--oc-l) 40%, transparent), color-mix(in srgb, var(--oc-l) 40%, transparent)) 0 calc(var(--pad) + var(--gap) * 4) / 100% 1px no-repeat;
  display: flex;
  flex-wrap: wrap;
  row-gap: 4px;
}
.staff-break { flex-basis: 100%; height: 0; }

.note {
  position: relative;
  flex: none;
  width: max(33px, calc(var(--b, 1) * 37px));
  height: var(--staff-h);
  background: var(--staff-lines);
}

.note-dot {
  position: absolute;
  left: 2px;
  top: calc(var(--pad) + (4 - var(--pos)) * var(--gap) - var(--dot) / 2);
  display: grid;
  place-items: center;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, color-mix(in srgb, var(--c) 45%, white) 0, var(--c) 55%);
  color: #0B1020;
  font-size: 0.8125rem;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(7, 10, 24, 0.95), 0 0 12px -3px var(--c);
  transition: transform 0.3s var(--spring), box-shadow 0.25s ease;
}
.oc-song .note[data-midi] .note-dot { cursor: pointer; }
.note.is-on .note-dot {
  transform: scale(1.32);
  transition-duration: 0.12s;
  box-shadow: 0 0 0 2px rgba(7, 10, 24, 0.95), 0 0 22px 3px var(--c);
}

/* ↑ or ↓ for a half step, perched on the note. */
.note-mod {
  position: absolute;
  top: -7px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 1px solid var(--c);
  border-radius: 50%;
  background: #0B1020;
  color: var(--star);
  font-size: 0.6875rem;
  font-weight: 800;
}

/* ---------- The songs ---------- */

.oc-songs { padding-block: clamp(2rem, 6vh, 4rem) clamp(4rem, 10vh, 6rem); }

.oc-songs-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem 2rem;
  margin-bottom: 1.75rem;
}
.oc-h2 {
  margin: 0;
  color: var(--star);
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 850;
  font-variation-settings: "wdth" 62;
  line-height: 0.95;
  text-transform: uppercase;
}
.oc-read {
  max-width: 40rem;
  margin: 0.75rem 0 0;
  color: var(--dust);
  font-size: 0.9375rem;
}
.oc-read b { color: var(--star); }

.oc-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.oc-seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--oc-panel);
}
.oc-seg[hidden] { display: none; }
.oc-seg button {
  min-height: 40px;
  padding: 0.4rem 0.95rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--dust);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.oc-seg button:hover { color: var(--star); }
.oc-seg button[aria-pressed="true"] { background: rgba(238, 242, 255, 0.13); color: var(--star); }

/* Kinds of song: chips that wrap on narrow screens. */
.oc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.25rem 0 1.5rem;
}
.oc-chips button {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  min-height: 40px;
  padding: 0.4rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--oc-panel);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.oc-chips button:hover { border-color: rgba(238, 242, 255, 0.35); color: var(--star); }
.oc-chips button[aria-pressed="true"] {
  border-color: var(--star);
  background: var(--star);
  color: var(--sky-1);
}
.oc-chip-n { opacity: 0.6; font-weight: 600; }

.oc-list {
  display: grid;
  gap: clamp(1rem, 2vw, 1.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 1000px) {
  .oc-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

.oc-song {
  min-width: 0;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--oc-panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  scroll-margin-top: calc(var(--header-h) + 1rem);
  transition: border-color 0.3s ease, box-shadow 0.4s ease;
}
.oc-song.is-playing {
  border-color: rgba(245, 217, 168, 0.5);
  box-shadow: 0 0 40px -14px rgba(245, 217, 168, 0.6);
}
.oc-song.is-found { animation: oc-found 2.4s var(--ease-out); }
@keyframes oc-found {
  0%, 30% { border-color: var(--gold-hi); box-shadow: 0 0 50px -8px rgba(245, 217, 168, 0.85); }
}

.oc-song-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.oc-song-title {
  margin: 0;
  color: var(--star);
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.oc-song-by {
  margin: 0.2rem 0 0;
  color: var(--dust);
  font-size: 0.875rem;
}
.oc-badge {
  flex: none;
  margin-top: 0.15rem;
  padding: 0.2rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--dust);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}
.oc-badge--plain { border-color: rgba(61, 220, 132, 0.45); color: var(--materia-green); }

.oc-song .staff { margin: 1.1rem 0 1.25rem; }

.oc-play {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.55rem 1.25rem 0.55rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--star);
  color: var(--sky-1);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px -14px rgba(238, 242, 255, 0.5);
  transition: transform 0.45s var(--spring), background-color 0.2s ease, box-shadow 0.25s ease;
}
.oc-play:hover { transform: translateY(-2px) scale(1.03); background: #fff; }
.oc-play:active { transform: translateY(1px) scale(0.97); transition-duration: 0.1s; }
.oc-play-icon { width: 18px; height: 18px; fill: currentColor; }
.oc-song.is-playing .oc-play { background: var(--gold-hi); }

.oc-noscript { color: var(--dust); }
.oc-read a { color: var(--star); text-underline-offset: 0.2em; }

/* ---------- Make your own ---------- */

.oc-make {
  padding-block: 0 clamp(4rem, 10vh, 6rem);
  scroll-margin-top: var(--header-h);
}
.oc-make-panel {
  max-width: 48rem;
  margin-top: 1.25rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--oc-panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.oc-make-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--star);
  font-size: 0.9375rem;
  font-weight: 650;
}
.oc-make textarea {
  display: block;
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(4, 6, 14, 0.7);
  color: var(--star);
  font: 500 0.9375rem/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.oc-make textarea::placeholder { color: rgba(154, 165, 196, 0.6); }
.oc-make textarea:focus,
.oc-make-bpm input:focus {
  outline: none;
  border-color: var(--gold-hi);
  box-shadow: 0 0 0 3px rgba(245, 217, 168, 0.18);
}
.oc-make-help {
  margin: 0.6rem 0 0;
  color: var(--dust);
  font-size: 0.8125rem;
  line-height: 1.55;
}
.oc-make-help code {
  padding: 0.05em 0.35em;
  border-radius: 4px;
  background: rgba(238, 242, 255, 0.08);
  color: var(--star);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.oc-make-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}
.oc-make-bpm {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--dust);
  font-size: 0.875rem;
}
.oc-make-bpm input {
  width: 4.75rem;
  min-height: 40px;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(4, 6, 14, 0.7);
  color: var(--star);
  font: inherit;
  font-size: 0.9375rem;
}
.oc-go { padding-left: 1.25rem; }
.oc-make-status {
  margin: 0.75rem 0 0;
  min-height: 1.5em;
  color: var(--dust);
  font-size: 0.875rem;
}
.oc-make-status.is-error { color: #FF9AA0; }
.oc-make-result { margin-top: 0.75rem; }
.oc-make-result:empty { display: none; }
.oc-make-result .oc-song { background: rgba(4, 6, 14, 0.55); }
