/* =====================================================================
   THE MUSIC VISUALIZER (music-visualizer.html)
   Only that page loads this file; css/style.css does the rest of the page.
   The screen is a dark display set into the paper page, like a TV in a
   living room. "Fill the screen" lifts the same box over the whole
   window, and the controls tuck away while the music plays.
   ===================================================================== */
.screen {
  --void: #07050d;                       /* the screen's own black */
  --screen-ink: #f0eaff;                 /* text on the screen */
  --screen-dim: rgba(240, 234, 255, .66);
  --screen-line: rgba(185, 110, 255, .32);
  --scrim: rgba(7, 5, 13, .94);
  --scrim-mid: rgba(7, 5, 13, .6);
  --scrim-clear: rgba(7, 5, 13, 0);
  position: relative; aspect-ratio: 16 / 9; background: var(--void); color: var(--screen-ink);
  border-radius: 16px; overflow: hidden; box-shadow: 0 16px 34px rgba(35, 31, 32, .25);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
@media (max-width: 680px) { .screen { aspect-ratio: 4 / 5; } }
.screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; background: var(--void); }
.screen.ui-off { cursor: none; }

/* theater mode: the same box, over everything */
body.vis-theater { overflow: hidden; }
body.vis-theater .screen { position: fixed; inset: 0; z-index: 80; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
body.vis-theater .screen .dock { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
body.vis-theater .screen .titlecard { top: calc(16% + env(safe-area-inset-top, 0px)); }
body.vis-theater .screen .rec-badge { top: calc(14px + env(safe-area-inset-top, 0px)); }

/* the control dock, a scrim along the bottom edge */
.dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: grid; gap: 6px; padding: 56px 16px 12px;
  background: linear-gradient(to top, var(--scrim) 0%, var(--scrim) 36%, var(--scrim-clear) 100%);
  transition: opacity .45s ease, transform .45s ease;
}
.screen.ui-off .dock { opacity: 0; transform: translateY(22px); pointer-events: none; }
.nowline { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-width: 0; }
.nowline .track { flex: 1; min-width: 0; font: 700 16px/1.3 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nowline .time { flex: none; font: 600 11px/1.4 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--screen-dim); font-variant-numeric: tabular-nums; }

.seek { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer; --p: 0%; }
.seek:disabled { opacity: .35; cursor: default; }
.seek::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--violet-light) var(--p), rgba(240, 234, 255, .18) var(--p)); }
.seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--screen-ink); box-shadow: 0 0 0 4px rgba(143, 0, 255, .42), 0 0 14px var(--violet-light); }
.seek::-moz-range-track { height: 3px; border-radius: 2px; background: rgba(240, 234, 255, .18); }
.seek::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--violet-light); }
.seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--screen-ink); box-shadow: 0 0 0 4px rgba(143, 0, 255, .42), 0 0 14px var(--violet-light); }
.seek:focus-visible { outline: 3px solid var(--violet-light); outline-offset: 2px; border-radius: 4px; }

.transport-row { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.transport-main { display: flex; align-items: center; gap: 6px; }
.transport-side { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.icon { flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--screen-ink); cursor: pointer; }
.icon svg { display: block; width: 24px; height: 24px; }
.icon:disabled { opacity: .3; cursor: default; }
.icon:hover:not(:disabled) { background: rgba(240, 234, 255, .1); }
.icon.play { width: 56px; height: 56px; background: var(--violet); box-shadow: 0 0 0 5px rgba(143, 0, 255, .35), 0 0 26px rgba(143, 0, 255, .5); }
.icon.play svg { width: 26px; height: 26px; }
.icon.play:hover:not(:disabled) { background: var(--violet-light); }
.icon.play.nudge { animation: nudge 1.3s ease-in-out infinite; }
@keyframes nudge { 50% { box-shadow: 0 0 0 12px rgba(143, 0, 255, 0), 0 0 40px var(--violet-light); } }
.icon:focus-visible, .chip:focus-visible, .scene-chip:focus-visible { outline: 3px solid var(--violet-light); outline-offset: 3px; }

.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 13px; border: 1px solid var(--screen-line); border-radius: 999px; background: var(--scrim-mid); color: var(--screen-ink); font: 700 10.5px/1 var(--font-label); letter-spacing: .12em; text-transform: uppercase; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--violet-light); }
.chip svg { width: 16px; height: 16px; flex: none; }
@media (max-width: 520px) {   /* on a phone the transport and the two chips share one row, so the theater chip keeps only its icon */
  .transport-side { margin-left: 0; }
  #theaterBtn { padding: 0 10px; }
  #theaterBtn #theaterLabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dock { padding-top: 44px; gap: 4px; }
}
.swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--sw, var(--violet)); box-shadow: 0 0 9px var(--sw, var(--violet)); }
.swatch.rainbow { background: conic-gradient(#ff3b3b, #ffd23b, #3bff6a, #3bd9ff, #4b5bff, #e23bff, #ff3b3b); box-shadow: 0 0 9px rgba(255, 255, 255, .55); }

/* the quiet line that puts on the house band */
.band-line { padding-top: 6px; }
.linkish { padding: 0; border: 0; background: none; color: var(--violet-light); font: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; cursor: pointer; }
.linkish:hover { color: var(--paper); }

.scene-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.scene-chips::-webkit-scrollbar { display: none; }
.scene-chip { flex: none; min-height: 34px; padding: 0 12px; border: 1px solid var(--screen-line); border-radius: 999px; background: transparent; color: var(--screen-dim); font: 700 10px/1 var(--font-label); letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.scene-chip[aria-pressed="true"] { color: #fff; background: var(--violet); border-color: var(--violet); box-shadow: 0 0 16px rgba(143, 0, 255, .5); }

/* the handwritten title card for each song */
.titlecard { position: absolute; left: 16px; right: 16px; top: 12%; z-index: 2; display: grid; gap: 6px; justify-items: center; text-align: center; pointer-events: none; opacity: 0; }
.titlecard.show { animation: card 4.8s cubic-bezier(.2, .7, .2, 1) both; }
.tc-kicker { font: 700 10.5px/1.4 var(--font-label); letter-spacing: .2em; text-transform: uppercase; color: var(--screen-dim); }
.tc-name { margin: 0; max-width: 18ch; font: 700 clamp(34px, 8vw, 84px) / 1 var(--font-hand); color: var(--screen-ink); text-shadow: 0 0 30px rgba(143, 0, 255, .55), 0 0 2px var(--violet-light); text-wrap: balance; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@keyframes card { 0% { opacity: 0; transform: translateY(10px); filter: blur(8px); } 20% { opacity: 1; transform: none; filter: blur(0); } 78% { opacity: 1; } 100% { opacity: 0; filter: blur(3px); } }

/* the scene's name, flashed when it changes */
.scene-toast { position: absolute; left: 50%; top: 14px; z-index: 4; margin: 0; padding: 8px 14px; border: 1px solid var(--screen-line); border-radius: 999px; background: var(--scrim); color: var(--screen-ink); font: 700 10.5px/1 var(--font-label); letter-spacing: .24em; text-transform: uppercase; opacity: 0; transform: translate(-50%, -6px); transition: opacity .3s ease, transform .3s ease; pointer-events: none; }
.scene-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* recording */
.rec-badge { position: absolute; left: 14px; top: 14px; z-index: 4; margin: 0; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; background: var(--scrim); color: #fff; font: 700 10.5px/1 var(--font-label); letter-spacing: .14em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tape-red); animation: blink 1s steps(2) infinite; }
.rec-note { font: 600 11px/1.7 var(--font-label); letter-spacing: .08em; text-transform: uppercase; color: var(--fg-soft); max-width: 60ch; }
.rec-note.warn { color: var(--crumb); }

/* the scene cards: index cards, like the tools' knob cards */
.scene-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 30px 24px; }
.scene-card { --r: 0deg; position: relative; display: grid; gap: 10px; align-content: start; justify-items: start; min-width: 0; padding: 28px 20px 20px; border: 0; color: var(--card-ink); background: var(--card); text-align: left; cursor: pointer; box-shadow: 0 10px 22px rgba(35, 31, 32, .18), 0 1px 0 rgba(35, 31, 32, .1); transform: rotate(var(--r)); transition: transform .15s ease, box-shadow .15s ease; font: 400 15.5px/1.5 var(--font-body); }
.scene-card:nth-child(4n+1) { --r: -.6deg; } .scene-card:nth-child(4n+2) { --r: .4deg; } .scene-card:nth-child(4n+3) { --r: -.3deg; } .scene-card:nth-child(4n) { --r: .5deg; }
.scene-card:hover { transform: rotate(0deg) translateY(-2px); }
.scene-card .tape { position: absolute; top: -11px; left: 14px; }
.scene-card strong { font: 800 19px/1.25 var(--font-body); color: var(--card-ink); }
.scene-card > span:last-child { color: var(--card-ink-soft); }
.scene-card[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--violet), 0 10px 22px rgba(35, 31, 32, .18); }
.scene-card:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

.download select#recSize { max-width: 100%; }
html:not(.font-plain) :is(.nowline .time, .chip, .scene-chip, .tc-kicker, .scene-toast, .rec-badge, .rec-note) { font-size-adjust: .58; }

@media (prefers-reduced-motion: reduce) {
  .titlecard.show { animation: cardfade 4.8s ease both; }
  .icon.play.nudge, .rec-dot { animation: none; }
  .dock, .scene-toast, .scene-card { transition: none; }
}
@keyframes cardfade { 0%, 100% { opacity: 0; } 15%, 80% { opacity: 1; } }
