/* ==============================================================
   MUSIC BOX · page styles
   File: /music-box/music-box.css
   Colours, font and buttons come from site.css.
   The "How it helps" section uses shared styles (site.css, section 13).
   Pin and velvet colours live in music-box.js (section 1).

   Sections:
     1  Layout and intro
     2  The box and its velvet
     3  The comb (note keys)
     4  Controls
   ============================================================== */


/* --------------------------------------------------------------
   1 · LAYOUT AND INTRO
   -------------------------------------------------------------- */
.musicroom {
  padding-block: clamp(1.5rem, 5vw, 3rem) clamp(3rem, 8vw, 5rem);
  background: linear-gradient(var(--c-sky-top), var(--bg));
}
.musicroom__intro { max-width: 44rem; margin-bottom: clamp(1.25rem, 3vw, 2rem); }
.musicroom__title {
  margin-bottom: .35em;
  font-size: clamp(2.4rem, 1.6rem + 3vw, 4rem);
  font-weight: var(--weight-light);
  letter-spacing: -.025em;
}
.musicroom__lede {
  font-size: var(--step-1);
  font-weight: var(--weight-light);
  line-height: 1.45;
}


/* --------------------------------------------------------------
   2 · THE BOX AND ITS VELVET
   -------------------------------------------------------------- */
.musicbox {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 70svh;
  margin-inline: auto;
  padding: clamp(10px, 1.6vw, 18px);
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .035) 0 2px, transparent 2px 11px),
    linear-gradient(135deg, #6A4631, #3E291C);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .15);
}
@media (max-width: 700px) {
  .musicbox { aspect-ratio: 4 / 5; }
}
.musicbox canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.musicbox__start {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: .5rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  color: #F6EBD7;
  font-size: 1rem;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: opacity .6s ease;
  animation: start-pulse 2.8s ease-in-out infinite;
}
.musicbox__start.is-gone { opacity: 0; animation: none; }
@keyframes start-pulse {
  50% { opacity: .55; }
}


/* --------------------------------------------------------------
   3 · THE COMB (one key per note)
   Like the metal comb inside a music box: long teeth for low
   notes, short teeth for high notes.
   -------------------------------------------------------------- */
.comb {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(3px, 0.8vw, 8px);
  max-width: 44rem;
  margin: 1rem auto 0;
}
.comb__key {
  appearance: none;
  flex: 1 1 0;
  max-width: 2.6rem;
  min-width: 0;
  height: var(--len);
  border: 0;
  border-radius: 0 0 999px 999px;
  background: linear-gradient(90deg, #A9A49A, #E8E3D9 45%, #9C968B);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
  cursor: pointer;
  transition: transform .12s ease, filter .12s ease;
}
.comb__key:hover { filter: brightness(1.06); }
.comb__key.is-ringing { transform: translateY(3px); filter: brightness(1.15); }


/* --------------------------------------------------------------
   4 · CONTROLS
   -------------------------------------------------------------- */
.music-panel {
  max-width: 52rem;
  margin: 1.5rem auto 0;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow);
}
.music-panel__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: 1.25rem 2rem;
}
.music-choice {
  margin: 0;
  padding: 0;
  border: 0;
}
.music-choice legend,
.music-choice__legend {
  padding: 0;
  margin-bottom: .5rem;
  font-size: var(--step--1);
  font-weight: var(--weight-strong);
}
.music-choice__row { display: flex; flex-wrap: wrap; gap: .4rem; }

.music-pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 42px;
  padding: .35rem .95rem .35rem .8rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-size: .95rem;
}
.music-pill input { margin: 0; width: 1rem; height: 1rem; accent-color: var(--accent); }
.music-pill:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.music-pill:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }

.music-check {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .9rem;
  cursor: pointer;
}
.music-check input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); }

.music-volume {
  display: grid;
  gap: .3rem;
  font-size: var(--step--1);
  font-weight: var(--weight-strong);
}
.music-volume input { width: 100%; accent-color: var(--accent); }

.music-status {
  min-height: 1.65em;
  margin-top: 1rem;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .musicbox__start { animation: none; }
  .comb__key { transition: none; }
}
