/* DJ mode — corner turntable, beat-synced hero pulse, BPM control.
 * The beat drives --beat-duration; dj.js also rescales the global
 * --duration-* motion tokens so BPM literally sets the site's tempo. */

.dj {
  position: fixed;
  right: var(--space-6);
  bottom: var(--space-6);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
  /* Its own view-transition group: the deck stays visually untouched
   * while the rest of the page crossfades during navigation. */
  view-transition-name: dj-deck;
}

/* Hidden while the splash owns the screen; revealed when its record lands. */
.dj.is-hidden {
  visibility: hidden;
}

/* Phones: shrink the whole widget (scale keeps the deck art intact,
 * since its parts are absolutely sized). */
@media (max-width: 640px) {
  .dj {
    right: var(--space-4);
    bottom: var(--space-4);
    transform: scale(0.8);
    transform-origin: bottom right;
  }
}

.dj-deck {
  position: relative;
  width: 72px;
  height: 72px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-default);
  box-shadow: var(--shadow-md);
  cursor: grab;
  touch-action: none;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.dj.is-dragging .dj-deck {
  cursor: grabbing;
  transform: scale(1.05);
}

/* Armed after navigation: music resumes on the next interaction. */
.dj.is-armed .dj-deck {
  animation: dj-armed 1.6s var(--ease-in-out) infinite;
}

@keyframes dj-armed {
  0%,
  100% {
    box-shadow: var(--shadow-md);
  }
  50% {
    box-shadow: 0 0 0 6px var(--accent-soft), var(--shadow-md);
  }
}

.dj-deck:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.dj-record {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: repeating-radial-gradient(
    circle at center,
    #2b2624 0 2px,
    #383230 2px 4px
  );
  display: grid;
  place-items: center;
  animation: dj-spin 1.8s linear infinite;
  animation-play-state: paused;
}

.dj.is-playing .dj-record {
  animation-play-state: running;
}

.dj-record::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--accent-default);
  border: 2px solid var(--oat-0);
}

.dj-arm {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 4px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--oat-500);
  transform-origin: top center;
  transform: rotate(-28deg);
  transition: transform var(--duration-base) var(--ease-out);
}

.dj.is-playing .dj-arm {
  transform: rotate(8deg);
}

.dj-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  animation: rise-in var(--duration-base) var(--ease-out) both;
}

/* Fully custom slider — native accent-color adds its own hover tint that
 * clashes with the palette. --dj-bpm-fill is set from dj.js. */
.dj-panel input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(
    to right,
    var(--accent-default) var(--dj-bpm-fill, 30%),
    var(--border-strong) var(--dj-bpm-fill, 30%)
  );
}

.dj-panel input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent-default);
  border: 2px solid var(--oat-0);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-out);
}

.dj-panel input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.dj-panel input[type="range"]::-moz-range-track {
  background: transparent;
}

.dj-panel input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background: var(--accent-default);
  border: 2px solid var(--oat-0);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-out);
}

.dj-panel input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
}

.dj-bpm-value {
  font-family: var(--font-mono);
  color: var(--accent-strong);
  min-width: 3ch;
  text-align: right;
}

/* Keep the fixed deck from covering the footer links. */
.site-footer-inner {
  padding-right: calc(72px + var(--space-8));
}

/* Beat-synced wash over the hero gradient. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--bg-wash);
  opacity: 0;
}

/* Only the home page breathes with the music — inner pages stay still. */
body.home.is-djing::before {
  animation: dj-pulse calc(var(--beat-duration, 714ms) * 2) var(--ease-in-out) infinite;
}

@keyframes dj-pulse {
  0%,
  100% {
    opacity: 0.06;
  }
  50% {
    opacity: 0.28;
  }
}

@keyframes dj-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Needle-drop splash ── */
body.has-splash {
  overflow: hidden;
}

.dj-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.dj-splash::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-default);
  transition: opacity 500ms var(--ease-out);
}

.dj-splash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-wash);
  transition: opacity 500ms var(--ease-out);
}

.dj-splash-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  text-align: center;
  animation: rise-in var(--duration-slow) var(--ease-out) both;
}

.dj-splash .dj-deck {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: transform 700ms var(--ease-in-out),
    box-shadow var(--duration-fast) var(--ease-out), opacity 400ms var(--ease-out);
}

.dj-splash .dj-record {
  left: 22px;
  top: 22px;
  width: 156px;
  height: 156px;
  background: repeating-radial-gradient(
    circle at center,
    #2b2624 0 5px,
    #383230 5px 10px
  );
}

.dj-splash .dj-record::after {
  width: 52px;
  height: 52px;
  border-width: 3px;
}

.dj-splash .dj-arm {
  right: 16px;
  top: 14px;
  width: 9px;
  height: 74px;
}

.dj-splash.is-leaving .dj-record {
  animation-play-state: running;
}

.dj-splash.is-leaving .dj-arm {
  transform: rotate(8deg);
}

.dj-splash-hint {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.dj-splash-sub {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.dj-splash-skip {
  border: none;
  background: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--duration-fast) var(--ease-out);
}

.dj-splash-skip:hover {
  color: var(--text-primary);
}

.dj-splash-text,
.dj-splash-skip {
  transition: opacity 300ms var(--ease-out);
}

.dj-splash.is-leaving::before,
.dj-splash.is-leaving::after,
.dj-splash.is-leaving .dj-splash-text,
.dj-splash.is-leaving .dj-splash-skip {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  body.is-djing::before {
    animation: none;
  }
  .dj-record {
    animation: none;
  }
  .dj.is-armed .dj-deck {
    animation: none;
  }
}
