/* Bloom — a light-and-sound instrument */

@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/jost-latin-300-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jost-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jost-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jost-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Jost';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/jost-latin-600-normal.woff2') format('woff2');
}

:root {
  --paper: #f8f5ee;
  --paper-raised: #fffdf7;
  --ink: #2c2836;
  --ink-soft: #555066;
  --ink-muted: #8d8799;
  --hairline: rgba(44, 40, 54, 0.16);
  --hairline-soft: rgba(44, 40, 54, 0.09);
  --active-ink: #2c2836;
  --danger: #c0392b;
  --ribbon-height: 124px;
  --console-width: 316px;
  --shadow-soft: 0 1px 2px rgba(44, 40, 54, 0.05), 0 8px 28px rgba(44, 40, 54, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Jost', 'Futura', 'Century Gothic', 'Avenir Next', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* the paper vignette is static — it lives in the page background where the
   compositor paints it once instead of the canvas shading it sixty times a
   second */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 120% 90% at 50% 42%,
    rgba(58, 50, 66, 0) 55%,
    rgba(58, 50, 66, 0.055) 100%
  );
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  cursor: crosshair;
}

/* ---------- masthead ---------- */

.masthead {
  position: fixed;
  top: 0;
  left: 0;
  padding: 26px 34px;
  z-index: 3;
  pointer-events: none;
}

.wordmark {
  font-size: 34px;
  font-weight: 300;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--ink);
}

.tagline {
  margin-top: 7px;
  font-size: 12.5px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

/* ---------- first-gesture hint ---------- */

.hint {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 3;
  pointer-events: none;
  opacity: 1;
  transition: opacity 1.1s ease;
  max-width: min(80vw, 480px);
}

.hint.hidden {
  opacity: 0;
}

.hint-line {
  display: block;
  font-size: 21px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  animation: hint-breathe 3.6s ease-in-out infinite;
}

.hint-sub {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
}

@keyframes hint-breathe {
  0%, 100% { opacity: 0.62; }
  50% { opacity: 1; }
}

/* ---------- console ---------- */

.console-open-wrap {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 5;
}

.console-toggle {
  display: none;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.console {
  position: fixed;
  top: 20px;
  right: 22px;
  width: var(--console-width);
  z-index: 4;
  background: var(--paper-raised);
  border: 1px solid var(--hairline-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  padding: 6px 18px 12px;
}

.console-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--hairline-soft);
}

.console-row:last-of-type {
  border-bottom: none;
}

.console-label {
  flex: 0 0 52px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding-top: 2px;
}

.chipset {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px 11px 4px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  border-color: var(--ink-soft);
}

.chip[aria-checked="true"],
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.loop-controls,
.time-controls,
.colour-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.ctl {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px 11px 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ctl:hover:not(:disabled) {
  border-color: var(--ink-soft);
}

.ctl:disabled {
  opacity: 0.38;
  cursor: default;
}

.ctl[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.ctl-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.4;
  flex: none;
}

#loop-record[aria-pressed="true"] .ctl-dot,
#take-record[aria-pressed="true"] .ctl-dot {
  background: #e0645a;
  opacity: 1;
}

#loop-record[aria-pressed="true"],
#take-record[aria-pressed="true"] {
  background: var(--danger);
  border-color: var(--danger);
  color: #fdf3f1;
}

.console-sep {
  width: 1px;
  height: 14px;
  background: var(--hairline);
  margin: 0 3px;
  flex: none;
}

.loop-meter {
  flex: 1 1 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--hairline-soft);
  overflow: hidden;
  margin-top: 4px;
}

.loop-meter-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ink-soft);
  border-radius: 2px;
}

.console-foot {
  padding-top: 9px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  line-height: 1.7;
  color: var(--ink-muted);
}

.console-foot kbd {
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 0 4px 1px;
  color: var(--ink-soft);
  background: var(--paper);
}

/* ---------- ribbon ---------- */

.ribbon-wrap {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--ribbon-height);
  z-index: 2;
  display: flex;
  align-items: stretch;
  padding: 0 0 0 0;
}

@media (min-width: 641px) {
  .ribbon-wrap {
    padding-right: 384px;
  }
}

@media (max-width: 640px) {
  .ribbon-wrap {
    padding-right: 52px;
  }
}

.ribbon {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 10px 8px 12px 10px;
}

.octave-shift {
  flex: 0 0 34px;
  font: inherit;
  font-size: 20px;
  font-weight: 300;
  color: var(--ink-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding-bottom: 6px;
  transition: color 0.15s ease;
}

.octave-shift:hover {
  color: var(--ink);
}

.ribbon-key {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
  font: inherit;
  background: var(--paper-raised);
  border: 1px solid var(--hairline-soft);
  border-radius: 9px;
  cursor: pointer;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  transition: transform 0.08s ease;
  touch-action: none;
}

.ribbon-key::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--key-hue, transparent);
  opacity: 0;
  transition: opacity 0.09s ease;
}

.ribbon-key.sounding::before {
  opacity: 0.24;
}

.ribbon-key.sounding {
  border-color: var(--key-edge, var(--hairline));
  transform: translateY(2px);
}

.ribbon-key .key-note {
  position: absolute;
  top: 9px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.ribbon-key .key-letter {
  position: relative;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  padding: 1px 6px 2px;
  background: var(--paper);
}

.ribbon-key.sounding .key-letter {
  color: var(--ink);
  border-color: var(--ink-soft);
}

.ribbon-key .key-letter.no-key {
  opacity: 0;
  border-color: transparent;
  background: transparent;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--ribbon-height) + 16px);
  transform: translateX(-50%) translateY(6px);
  z-index: 5;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--paper);
  background: rgba(44, 40, 54, 0.92);
  border-radius: 999px;
  padding: 7px 16px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  max-width: min(84vw, 480px);
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 641px) {
  .toast {
    left: calc(50% - 192px);
  }
}

/* ---------- no-audio notice ---------- */

.noaudio {
  position: fixed;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(88vw, 420px);
  background: var(--paper-raised);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 12px 18px;
  box-shadow: var(--shadow-soft);
}

.noaudio p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .masthead {
    padding: 18px 22px;
  }
  .wordmark {
    font-size: 26px;
  }
  .tagline {
    font-size: 11px;
  }
}

@media (max-width: 720px) {
  :root {
    --ribbon-height: 102px;
  }

  .console {
    display: none;
    top: 64px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100vh - var(--ribbon-height) - 90px);
    overflow-y: auto;
  }

  .console.open {
    display: block;
  }

  .console-toggle {
    display: block;
  }

  .hint {
    top: 27%;
  }

  .hint-line {
    font-size: 17px;
  }

  .hint-sub {
    font-size: 12px;
  }

  .ribbon {
    gap: 3px;
    padding: 8px 5px 10px 7px;
  }

  .ribbon-key .key-letter {
    display: none;
  }

  .octave-shift {
    flex-basis: 26px;
  }
}

@media (max-height: 500px) {
  .masthead {
    padding: 12px 18px;
  }
  .wordmark {
    font-size: 20px;
  }
  .tagline {
    display: none;
  }
  .hint {
    top: 18%;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .hint-line {
    animation: none;
    opacity: 0.85;
  }
  .ribbon-key,
  .ribbon-key::before,
  .toast,
  .chip,
  .ctl {
    transition: none;
  }
}
