/* Concert mode: full-screen show for an analysed track (src/ui/concert.js).
   Always dark, whatever the page theme. --cc-base / --cc-accent (r,g,b) follow
   the palette (set ~10 times a second); per-frame movement is transforms only
   (compositor, nothing is repainted per frame). */

/* entries: detail dialog button, library row button */
.cc-open-btn .cc-spark, .cc-row-btn { color: var(--accent); }
.cc-row-btn { font-size: 0.95rem; margin-left: 2px; }

html.concert-on, html.concert-on body { overflow: hidden; }

.concert {
  --cc-base: 59, 130, 246;
  --cc-accent: 6, 182, 212;
  --cc-display: "Space Grotesk", "Anton", "Bebas Neue", "Oswald", Impact, Haettenschweiler, "Arial Narrow Bold", "Roboto Condensed", "Helvetica Neue", system-ui, sans-serif;
  --cc-text: #f5f7fb;
  --cc-pad-y: clamp(14px, 3vh, 36px);
  --cc-pad-x: clamp(16px, 3.5vw, 56px);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  box-sizing: border-box;
  z-index: 10000;
  background: #000;
  color: var(--cc-text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
}
.concert *, .concert *::before, .concert *::after { box-sizing: border-box; }
.concert[hidden] { display: none !important; }
.concert.in { opacity: 1; }
.concert.ui-idle { cursor: none; }
/* full screen: the element is the whole screen, nothing else shows */
.concert:fullscreen { width: 100vw; height: 100vh; inset: 0; background: #000; }
.concert::backdrop { background: #000; }

.cc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.cc-hud {
  position: absolute; inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: clamp(8px, 1.6vh, 18px);
  padding: var(--cc-pad-y) var(--cc-pad-x);
  pointer-events: none;
}
/* scrims: the HUD stays readable over a white-hot scene */
.cc-hud::before, .cc-hud::after { content: ""; position: absolute; left: 0; right: 0; pointer-events: none; z-index: -1; }
.cc-hud::before { top: 0; height: 18%; background: linear-gradient(rgba(0, 0, 0, 0.45), transparent); }
.cc-hud::after { bottom: 0; height: 34%; background: linear-gradient(transparent, rgba(0, 0, 0, 0.62)); }
.cc-hud { z-index: 0; }
.cc-center, .cc-bottom, .cc-strip-row { transition: opacity 0.6s ease, transform 0.6s ease; }

/* top bar */
.cc-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-width: 0; }
.cc-status {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.cc-status .cc-phase { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, 0.35); flex: none; }
.concert.live .cc-dot { background: #ff3b3b; box-shadow: 0 0 12px #ff3b3b; animation: cc-blink 1.6s ease-in-out infinite; }
@keyframes cc-blink { 50% { opacity: 0.35; } }

.cc-actions { display: flex; gap: 8px; flex: none; pointer-events: auto; transition: opacity 0.6s ease, transform 0.6s ease; }
.cc-btn {
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  display: grid; place-items: center;
  font: inherit; font-size: 1.05rem; line-height: 1; color: #fff; cursor: pointer;
  background: rgba(10, 12, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.cc-btn:hover { background: rgba(var(--cc-accent), 0.35); border-color: rgba(var(--cc-accent), 0.9); transform: scale(1.06); }
.cc-btn:focus-visible { outline: 2px solid rgb(var(--cc-accent)); outline-offset: 3px; }
.cc-play { font-size: 0.95rem; letter-spacing: -0.1em; }
.concert.ui-idle .cc-actions,
.concert.ui-idle .cc-status { opacity: 0; transform: translateY(-8px); }
.concert.ui-idle .cc-actions { pointer-events: none; }

/* the window score, centred inside the spectrum ring */
.cc-center { display: grid; place-items: center; align-content: center; text-align: center; min-height: 0; overflow: hidden; }
.cc-num-wrap { will-change: transform; }
.cc-num {
  font-family: var(--cc-display);
  font-weight: 900;
  font-stretch: condensed;
  font-size: clamp(56px, 16vh, 210px);
  line-height: 0.9;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow:
    0 0 26px rgba(var(--cc-accent), 0.85),
    0 0 70px rgba(var(--cc-base), 0.6),
    0 4px 24px rgba(0, 0, 0, 0.55);
}
.cc-stage {
  margin-top: 0.35em;
  font-family: var(--cc-display);
  font-weight: 800;
  font-size: clamp(14px, 2.6vh, 30px);
  letter-spacing: 0.42em;
  padding-left: 0.42em; /* balances the tracking */
  text-transform: uppercase;
  color: color-mix(in srgb, rgb(var(--cc-accent)) 55%, #fff);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 18px rgba(var(--cc-accent), 0.7), 0 2px 12px rgba(0, 0, 0, 0.6);
}
.cc-stage.swap { animation: cc-rise 0.5s cubic-bezier(0.2, 0.9, 0.2, 1.2); }
@keyframes cc-rise { from { opacity: 0; transform: translateY(10px); letter-spacing: 0.7em; } }
.cc-next {
  margin-top: 1.1em; min-height: 1.4em;
  font-size: clamp(11px, 1.6vh, 16px); font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 0 4px #000, 0 0 10px rgba(0, 0, 0, 0.9), 0 1px 8px rgba(0, 0, 0, 0.9);
}
.cc-next.soon {
  color: #fff;
  font-size: clamp(13px, 2.2vh, 22px);
  text-shadow: 0 0 14px rgba(var(--cc-accent), 0.9), 0 1px 8px rgba(0, 0, 0, 0.9);
  animation: cc-throb 0.5s ease-in-out infinite alternate;
}
@keyframes cc-throb { to { transform: scale(1.08); opacity: 0.8; } }

/* off the charts: white hot, glitching type */
.concert.hot .cc-num { color: #fff; animation: cc-glitch 0.9s steps(1) infinite; }
.concert.hot .cc-stage { color: #fff; text-shadow: 0 0 3px #000, 0 0 18px rgba(255, 60, 200, 0.9), 0 2px 14px rgba(0, 0, 0, 0.9); }
@keyframes cc-glitch {
  0%, 100% { text-shadow: 0 0 40px rgba(255, 255, 255, 0.9), 0 0 90px rgba(var(--cc-accent), 0.8); transform: none; }
  12% { text-shadow: -6px 0 rgba(255, 40, 90, 0.9), 6px 0 rgba(40, 220, 255, 0.9), 0 0 60px #fff; transform: translate(3px, -1px) skewX(-6deg); }
  14% { transform: none; }
  47% { text-shadow: 5px 0 rgba(255, 40, 90, 0.9), -5px 0 rgba(40, 220, 255, 0.9), 0 0 60px #fff; transform: translate(-4px, 1px); clip-path: inset(10% 0 45% 0); }
  49% { transform: none; clip-path: none; }
  78% { text-shadow: -3px 0 rgba(255, 40, 90, 0.9), 3px 0 rgba(40, 220, 255, 0.9), 0 0 50px #fff; transform: skewX(4deg); }
  80% { transform: none; }
}
/* beyond the top of the scale: broken on purpose */
.concert.broken .cc-num { color: #fff; animation: cc-broken 1.3s steps(1) infinite; }
.concert.broken .cc-stage { color: #fff; letter-spacing: 0.6em; animation: cc-broken 0.9s steps(1) infinite reverse; }
@keyframes cc-broken {
  0%, 100% { transform: none; clip-path: none; text-shadow: -4px 0 #ff2a5a, 4px 0 #28dcff, 0 0 40px rgba(255, 255, 255, 0.8); opacity: 1; }
  9% { transform: translate(-7px, 3px) skewX(14deg); clip-path: inset(0 0 55% 0); text-shadow: 9px 0 #ff2a5a, -9px 0 #28dcff; }
  12% { transform: none; clip-path: none; text-shadow: -4px 0 #ff2a5a, 4px 0 #28dcff, 0 0 40px #fff; }
  31% { transform: translate(6px, -4px) scaleY(1.25); clip-path: inset(40% 0 8% 0); opacity: 0.6; }
  33% { transform: none; clip-path: none; opacity: 1; }
  52% { transform: translate(-3px, 0) skewX(-24deg); text-shadow: 14px 0 #ff2a5a, -14px 0 #28dcff; }
  54% { transform: none; text-shadow: -4px 0 #ff2a5a, 4px 0 #28dcff, 0 0 40px #fff; }
  71% { transform: translate(10px, 2px); clip-path: inset(62% 0 0 0); }
  73% { transform: translate(-4px, -2px); clip-path: inset(0 0 70% 0); }
  75% { transform: none; clip-path: none; }
  90% { opacity: 0.35; transform: scaleX(1.08); }
  92% { opacity: 1; transform: none; }
}

/* bottom: track (left), sub-scores (right) */
.cc-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; min-width: 0; }
.cc-track { display: flex; align-items: center; gap: clamp(12px, 1.6vw, 24px); min-width: 0; max-width: min(64vw, 900px); }
.cc-track.swap { animation: cc-slide 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes cc-slide { from { opacity: 0; transform: translateX(-24px); filter: blur(6px); } }
.cc-cover {
  flex: none;
  width: clamp(56px, 11vh, 128px); height: clamp(56px, 11vh, 128px);
  border-radius: 10px; overflow: hidden;
  display: grid; place-items: center;
  font-size: clamp(1.4rem, 4vh, 2.4rem); color: rgba(255, 255, 255, 0.7);
  background: linear-gradient(135deg, rgba(var(--cc-base), 0.6), rgba(var(--cc-accent), 0.25)), #0c0f16;
  box-shadow: 0 0 26px rgba(var(--cc-accent), 0.45), 0 16px 40px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.cc-cover img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: cover; display: block; }
.cc-meta { min-width: 0; }
.cc-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.3em; text-transform: uppercase; color: rgb(var(--cc-accent)); margin-bottom: 6px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
.cc-title {
  font-family: var(--cc-display);
  font-weight: 900;
  font-size: clamp(22px, 4.6vh, 56px);
  line-height: 1.02;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  overflow-wrap: anywhere;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7), 0 0 30px rgba(var(--cc-base), 0.45);
}
.cc-artist {
  margin-top: 8px;
  font-size: clamp(12px, 1.9vh, 19px);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

.cc-subs { display: flex; gap: 10px; align-items: flex-end; flex: none; transition: opacity 0.6s ease; }
.cc-sub { display: grid; justify-items: center; gap: 6px; width: 34px; }
.cc-sub-bar { width: 6px; height: clamp(40px, 9vh, 90px); border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; display: flex; align-items: flex-end; }
.cc-sub-bar i { will-change: transform; display: block; width: 100%; height: 100%; background: var(--c); box-shadow: 0 0 10px var(--c); transform-origin: bottom; transform: scaleY(0); border-radius: 3px; }
.cc-sub span {
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 0.62rem; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.6);
  max-height: 80px; overflow: hidden; white-space: nowrap;
}
.concert.ui-idle .cc-subs { opacity: 0.55; }

/* the whole track: intensity curve, sections, drops, playhead */
.cc-strip-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cc-time { flex: none; font-size: 0.78rem; font-weight: 600; font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.8); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); min-width: 3.4em; }
.cc-total { text-align: right; }
.cc-strip {
  position: relative; flex: 1; min-width: 0;
  height: clamp(28px, 4.5vh, 46px);
  border-radius: 6px; overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: auto; cursor: pointer;
  touch-action: none;
}
.cc-strip:focus-visible { outline: 2px solid rgb(var(--cc-accent)); outline-offset: 2px; }
.cc-strip-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cc-strip-fill {
  position: absolute; inset: 0; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, rgba(var(--cc-base), 0.08), rgba(var(--cc-accent), 0.22));
  mix-blend-mode: screen; will-change: transform;
}
.cc-strip-head {
  position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; will-change: transform;
  background: #fff; box-shadow: 0 0 10px rgb(var(--cc-accent)), 0 0 3px #fff;
}
.concert.ui-idle .cc-strip-row { opacity: 0.45; }

/* section names and drops: a title card across the screen */
.cc-banner {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; overflow: hidden;
}
.cc-banner span {
  font-family: var(--cc-display); font-weight: 900; text-transform: uppercase; white-space: nowrap;
  font-size: clamp(48px, 17vw, 300px); letter-spacing: 0.08em; line-height: 1;
  color: transparent; -webkit-text-stroke: 2px rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 40px rgba(var(--cc-accent), 0.5);
  opacity: 0;
}
.cc-banner.show span { animation: cc-card 1.6s cubic-bezier(0.15, 0.8, 0.25, 1) both; }
.cc-banner.big span { color: rgba(255, 255, 255, 0.08); -webkit-text-stroke: 3px #fff; font-size: clamp(64px, 24vw, 420px); }
@keyframes cc-card {
  0% { opacity: 0; transform: scale(1.6); letter-spacing: 0.5em; filter: blur(8px); }
  18% { opacity: 1; transform: scale(1); letter-spacing: 0.08em; filter: none; }
  70% { opacity: 0.8; }
  100% { opacity: 0; transform: scale(0.92); letter-spacing: 0.02em; }
}

/* build-up: the number tightens and glows */
.concert.tense .cc-num { text-shadow: 0 0 36px rgba(255, 255, 255, 0.7), 0 0 90px rgba(var(--cc-accent), 0.9); }

/* paused / starting / failed */
.cc-idle {
  position: absolute; left: 0; right: 0; bottom: 22%;
  display: grid; justify-items: center; text-align: center; gap: 8px;
  padding: 0 24px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
}
.concert.paused .cc-idle { opacity: 1; }
.cc-idle-title {
  font-family: var(--cc-display);
  font-weight: 900;
  font-size: clamp(22px, 4vh, 44px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 30px rgba(var(--cc-accent), 0.6), 0 2px 12px rgba(0, 0, 0, 0.8);
}
.cc-idle-text { margin: 0; max-width: 52em; font-size: clamp(12px, 1.8vh, 16px); line-height: 1.5; color: rgba(255, 255, 255, 0.78); text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9); }
.concert.paused .cc-next { opacity: 0; }

@media (max-width: 760px), (max-height: 520px) {
  .cc-subs { display: none; }
  .cc-track { max-width: 100%; }
}
@media (max-height: 520px) {
  .cc-cover { display: none; }
  .cc-kicker { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .concert, .cc-center, .cc-bottom, .cc-idle, .cc-strip-row { transition-duration: 0.01s; }
  .concert.hot .cc-num, .concert.broken .cc-num, .concert.broken .cc-stage, .cc-dot, .cc-stage.swap, .cc-track.swap, .cc-next.soon { animation: none !important; }
  .cc-banner.show span { animation: cc-fade 1.4s ease both; }
}
@keyframes cc-fade { 0%, 100% { opacity: 0; } 25%, 60% { opacity: 0.8; } }

/* keeps the white number readable over the white-hot centre */
.concert.hot .cc-num-wrap, .concert.broken .cc-num-wrap { background: radial-gradient(closest-side, rgba(8, 0, 16, 0.55), transparent); border-radius: 50%; padding: 0.1em 0.3em; }

/* visual delay: − value + (tunes the sync with what is heard) */
.cc-sync {
  display: flex; align-items: center; gap: 2px; height: 44px; padding: 0 4px; border-radius: 22px;
  background: rgba(10, 12, 18, 0.55); border: 1px solid rgba(255, 255, 255, 0.22);
}
.cc-sync-btn {
  width: 32px; height: 32px; border-radius: 50%; padding: 0; border: 0; cursor: pointer;
  font: inherit; font-size: 1.1rem; line-height: 1; color: #fff; background: transparent;
  transition: background 0.2s;
}
.cc-sync-btn:hover { background: rgba(var(--cc-accent), 0.35); }
.cc-sync-btn:focus-visible { outline: 2px solid rgb(var(--cc-accent)); outline-offset: 1px; }
.cc-sync-val {
  min-width: 4.6em; text-align: center; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.8); transition: color 0.3s;
}
.concert.sync-shown .cc-sync-val { color: rgb(var(--cc-accent)); }
@media (max-width: 560px) { .cc-sync-val { min-width: 3.6em; font-size: 0.68rem; } }

/* beat meter under the stage: a light on each kick, tempo and attacks per second */
.cc-meter {
  margin-top: 0.7em; display: flex; align-items: center; justify-content: center; gap: 0.6em; min-height: 1.2em;
  font-size: clamp(10px, 1.4vh, 14px); font-weight: 700; letter-spacing: 0.2em; text-transform: uppercase;
  font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 0 4px #000, 0 1px 8px rgba(0, 0, 0, 0.9);
}
.cc-led {
  width: 0.7em; height: 0.7em; border-radius: 50%; flex: none; will-change: transform, opacity;
  background: rgb(var(--cc-accent)); box-shadow: 0 0 10px rgb(var(--cc-accent)), 0 0 3px #fff;
}
.concert.paused .cc-meter { opacity: 0.5; }

/* the page under the show is neither laid out nor painted while it runs */
html.concert-on body > :not(.concert):not(script):not(style):not(link) { content-visibility: hidden; }
