/*
 * Dark only, on purpose: this is read at night through a windscreen, and the
 * Tesla screen is the brightest thing in the cabin already.
 *
 * Performance notes for MCU2 (Intel Atom): one transformed container, no
 * backdrop-filter, no box-shadow on anything that moves, no per-frame layout.
 */

:root {
  color-scheme: dark;

  --bg: #08080b;
  --text: #f6f6f8;
  --dim: #6d6d7a;
  --dimmer: #474754;
  --accent: #7de2c3;
  --danger: #ff8f8f;

  --line-size: clamp(30px, 5.2vh, 60px);
  --line-gap: clamp(18px, 3.2vh, 38px);
  --gutter: clamp(20px, 4vw, 64px);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* The screen is a touch target, not a document. */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: var(--gutter);
}

/* ------------------------------------------------------------ now playing */

#nowPlaying { text-align: center; }

#title {
  margin: 0;
  font-size: clamp(15px, 2.1vh, 22px);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#artist {
  margin: 0.2em 0 0;
  font-size: clamp(13px, 1.7vh, 18px);
  color: var(--dimmer);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Spotify's Developer Terms require content to be attributed to Spotify. */
#attribution {
  margin: 0.35em 0 0;
  font-size: clamp(11px, 1.4vh, 14px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.75;
}

#attribution[hidden] { display: none; }

/* ---------------------------------------------------------------- lyrics */

#lyrics {
  position: relative;
  overflow: hidden;
  /* Fade the edges so lines enter and leave instead of being chopped. */
  mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
  -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent);
}

#scroller {
  position: absolute;
  inset-inline: 0;
  top: 0;
  will-change: transform;
  transition: transform 420ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.line {
  margin: 0 0 var(--line-gap);
  font-size: var(--line-size);
  font-weight: 620;
  line-height: 1.22;
  letter-spacing: -0.01em;
  text-align: center;
  text-wrap: balance;
  color: var(--dimmer);
  transition: color 280ms ease, opacity 280ms ease;
}

.line.is-past { color: var(--dimmer); opacity: 0.45; }
.line.is-next { color: var(--dim); }
.line.is-active { color: var(--text); }

/* Instrumental gaps are real lines with no words; keep the rhythm. */
.line:empty { min-height: calc(var(--line-size) * 0.4); }

/* --------------------------------------------------------------- interlude */

#interlude {
  display: flex;
  justify-content: center;
  gap: 0.6em;
  margin: 0;
  height: 1.4em;
  opacity: 0;
  transition: opacity 400ms ease;
}

#interlude.is-visible { opacity: 1; }

#interlude span {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}

#interlude span:nth-child(2) { animation-delay: 0.22s; }
#interlude span:nth-child(3) { animation-delay: 0.44s; }

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #scroller, .line, #interlude { transition: none; }
  #interlude span { animation: none; opacity: 0.7; }
}

/* ---------------------------------------------------------------- controls */

#controls {
  position: fixed;
  right: var(--gutter);
  bottom: var(--gutter);
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
}

#controls.is-visible { opacity: 1; pointer-events: auto; }

#controls button {
  min-width: 72px;
  height: 72px;
  padding: 0 18px;
  border: 1px solid #23232c;
  border-radius: 18px;
  background: #121218;
  color: var(--text);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

#controls button:active { background: #1c1c25; }

.dot {
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--danger);
  transition: background 300ms ease;
}

.dot.is-live { background: var(--accent); }

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: var(--bg);
  z-index: 10;
}

.overlay[hidden] { display: none; }

.panel { max-width: 34rem; text-align: center; }

.panel h2 {
  margin: 0 0 0.4em;
  font-size: clamp(24px, 3.6vh, 40px);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.panel p {
  margin: 0 0 1.4em;
  font-size: clamp(15px, 2.1vh, 20px);
  color: var(--dim);
  line-height: 1.5;
}

.panel .error { color: var(--danger); margin-top: 1em; margin-bottom: 0; }

#codeInput {
  width: 100%;
  padding: 20px;
  border: 1px solid #2a2a35;
  border-radius: 16px;
  background: #101016;
  color: var(--text);
  font: 700 clamp(28px, 4.4vh, 44px)/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.34em;
  text-align: center;
  text-transform: uppercase;
}

#codeInput:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

#codeSubmit {
  width: 100%;
  min-height: 72px;
  margin-top: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: #05271e;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

#codeSubmit:active { filter: brightness(0.92); }
