/* Ether: a 1920s etherphone at night.
   Warm filament = right hand (pitch). Ice = left hand (volume). */

:root {
  --night: #10122b;      /* background */
  --haze: #1d2047;       /* raised surfaces */
  --filament: #ffb35c;   /* right hand, pitch, the note */
  --ice: #8fd3ff;        /* left hand, volume */
  --mist: #e0e2f5;       /* main text */
  --dusk: #9095c0;       /* secondary text */

  --display: 'Poiret One', 'Didot', serif;
  --ui: 'Instrument Sans', system-ui, -apple-system, sans-serif;

  /* Set from app.js */
  --level: 0;          /* how loud the note is right now, 0-1 (drives the glow) */
  --volume: 0.7;       /* volume set by the left hand, 0-1 */
  --zone-top: 15vh;    /* where the playable band starts on screen */
  --zone-height: 70vh;
}

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

body {
  background: var(--night);
  color: var(--mist);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  height: 100vh;
  overflow: hidden;
}

video { display: none; }

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1); /* mirror, so it feels like a reflection */
}

button, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

/* ---------- Top bar ---------- */

.top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
}

.wordmark {
  font-family: var(--display);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: 0.06em;
}

.pill {
  background: none;
  border: 1px solid rgb(224 226 245 / 0.25);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
.pill:hover { border-color: rgb(224 226 245 / 0.5); }

/* ---------- The note (the one loud thing on screen) ---------- */

.note-display {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  text-align: center;
}

.note {
  font-family: var(--display);
  font-size: clamp(96px, 17vw, 240px);
  line-height: 1;
  color: var(--filament);
  min-height: 1em;
  text-shadow:
    0 0 calc(6px + var(--level) * 50px) rgb(255 179 92 / calc(0.2 + var(--level) * 0.6)),
    0 0 calc(var(--level) * 120px) rgb(255 179 92 / calc(var(--level) * 0.35));
  transition: opacity 0.15s;
}

.note-octave {
  font-size: 0.36em;
  margin-left: 0.04em;
  opacity: 0.75;
}

.note-state {
  min-height: 1.45em;
  margin-top: 12px;
  color: var(--dusk);
  font-size: 16px;
}

.is-muted .note { opacity: 0.3; }

/* ---------- Volume meter (left edge, left hand) ---------- */

.meter {
  position: fixed;
  left: 28px;
  top: var(--zone-top);
  height: var(--zone-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.meter-track {
  position: relative;
  flex: 1;
  width: 4px;
  border-radius: 2px;
  background: rgb(143 211 255 / 0.15);
}

.meter-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--volume) * 100%);
  border-radius: 2px;
  background: var(--ice);
  box-shadow: 0 0 12px rgb(143 211 255 / 0.6);
  transition: height 0.08s linear;
}

.meter-label {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ice);
  opacity: 0.8;
}

/* ---------- Note ladder (right edge, right hand) ---------- */

.ladder {
  position: fixed;
  right: 28px;
  top: var(--zone-top);
  height: var(--zone-height);
  width: 80px;
  list-style: none;
  pointer-events: none;
}

.ladder li {
  position: absolute;
  right: 0;
  top: calc(var(--pos) * 100%);
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ladder li::after {
  content: '';
  width: 10px;
  height: 2px;
  border-radius: 1px;
  background: rgb(255 179 92 / 0.3);
  transition: width 0.12s, background 0.12s;
}

.ladder .rung-label {
  font-size: 12px;
  color: var(--dusk);
}

.ladder li.is-root::after { width: 16px; }

.ladder li.is-active::after {
  width: 30px;
  background: var(--filament);
  box-shadow: 0 0 10px var(--filament);
}
.ladder li.is-active .rung-label { color: var(--filament); }

/* ---------- Controls ---------- */

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 40px 24px 22px;
  background: linear-gradient(to top, rgb(16 18 43 / 0.95), rgb(16 18 43 / 0));
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--dusk);
}

.control select,
.toggle {
  height: 38px;
  border-radius: 8px;
  border: 1px solid rgb(224 226 245 / 0.18);
  background-color: var(--haze);
  color: var(--mist);
  font-size: 14px;
  cursor: pointer;
}

.control select {
  appearance: none;
  padding: 0 32px 0 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239095c0' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.toggle {
  padding: 0 16px;
  color: var(--dusk);
}

.toggle[aria-pressed='true'] {
  color: var(--mist);
  border-color: rgb(224 226 245 / 0.55);
  background-color: rgb(224 226 245 / 0.12);
}

.control select:hover,
.toggle:hover { border-color: rgb(224 226 245 / 0.4); }

/* ---------- How to play ---------- */

.guide {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: rgb(16 18 43 / 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.guide[hidden] { display: none; }

.guide-panel { max-width: 620px; width: 100%; }

.guide-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 64px;
  line-height: 1;
  color: var(--filament);
  text-shadow: 0 0 30px rgb(255 179 92 / 0.45);
}

.guide-intro {
  margin-top: 16px;
  font-size: 17px;
  line-height: 1.55;
  max-width: 52ch;
}

.gesture-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 32px;
  margin-top: 28px;
}

.gesture-group h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}
.hand-right h3 { color: var(--filament); }
.hand-left h3 { color: var(--ice); }
.hand-both { grid-column: 1 / -1; }

.gesture-group dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 16px;
}
.gesture-group dt { font-weight: 500; }
.gesture-group dd { color: var(--dusk); }

.guide-keys {
  margin-top: 24px;
  color: var(--dusk);
}

kbd {
  font-family: var(--ui);
  font-size: 13px;
  color: var(--mist);
  padding: 1px 6px;
  border: 1px solid rgb(224 226 245 / 0.25);
  border-radius: 4px;
}

.primary {
  margin-top: 28px;
  height: 46px;
  padding: 0 26px;
  border: none;
  border-radius: 999px;
  background: var(--filament);
  color: var(--night);
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 0 24px rgb(255 179 92 / 0.35);
}
.primary:hover { box-shadow: 0 0 32px rgb(255 179 92 / 0.55); }

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
  .top { padding: 14px 16px; }
  .meter { left: 12px; }
  .ladder { right: 12px; width: 60px; }
  .controls { padding: 32px 16px 16px; gap: 10px; }
  .control select, .toggle { height: 34px; font-size: 13px; }
  .gesture-groups { grid-template-columns: 1fr; }
  .guide-title { font-size: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
