/* =====================================================================
   LetItSync depth layer: AMOLED blacks, tonal surfaces, and motion with
   real depth. The colours themselves are unchanged - only darkness, lift
   and movement. Everything animates transform/opacity only, so phones
   stay smooth, and all of it switches off under "reduce motion".
   ===================================================================== */
/* Motion and depth tokens (both themes). */
:root {
  /* motion */
  --spring: cubic-bezier(.34, 1.4, .5, 1);
  --glide: cubic-bezier(.22, 1, .36, 1);
  /* light above, shadow below: what makes a flat panel read as solid */
  --lift-1: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 2px 8px -4px rgba(0, 0, 0, .9);
  --lift-2: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 12px 28px -16px rgba(0, 0, 0, 1);
  --lift-3: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 26px 50px -24px rgba(0, 0, 0, 1);
  --ring: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 10px 34px -16px color-mix(in srgb, var(--accent) 60%, transparent);
}

/* True black only in dark mode; light mode keeps its own palette untouched. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --bg-2: #0b0b0c;
    --bg-3: #17181a;
    --bg-4: #2b2c30;
    --line: #1c1d20;
    --line-soft: rgba(255, 255, 255, .07);
    --card: rgba(12, 12, 14, .78);
    --field: rgba(0, 0, 0, .55);
    --topbar: rgba(0, 0, 0, .72);
    --mini-bg: rgba(8, 8, 10, .88);
    --shadow: 0 30px 60px -22px rgba(0, 0, 0, .95);
  }
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-2: #0b0b0c;
  --bg-3: #17181a;
  --bg-4: #2b2c30;
  --line: #1c1d20;
  --line-soft: rgba(255, 255, 255, .07);
  --card: rgba(12, 12, 14, .78);
  --field: rgba(0, 0, 0, .55);
  --topbar: rgba(0, 0, 0, .72);
  --mini-bg: rgba(8, 8, 10, .88);
  --shadow: 0 30px 60px -22px rgba(0, 0, 0, .95);
}
/* Softer shadows on white: the dark ones would look like smudges there. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --lift-1: 0 1px 2px rgba(16, 16, 20, .07);
    --lift-2: 0 2px 10px -4px rgba(16, 16, 20, .14);
    --lift-3: 0 18px 38px -22px rgba(16, 16, 20, .3);
  }
}
:root[data-theme="light"] {
  --lift-1: 0 1px 2px rgba(16, 16, 20, .07);
  --lift-2: 0 2px 10px -4px rgba(16, 16, 20, .14);
  --lift-3: 0 18px 38px -22px rgba(16, 16, 20, .3);
}

/* A faint pool of light behind everything, so black never looks empty. The page itself
   paints the black; the screens above it stay see-through so the light comes through. */
html { background: var(--bg); }
body, #home, #room, main { background: transparent; }
body::before {
  content: ""; position: fixed; inset: -20% -20% auto -20%; height: 70vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 55% at 22% 0%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%),
    radial-gradient(55% 50% at 85% 6%, color-mix(in srgb, var(--play) 9%, transparent), transparent 72%);
  animation: aurora 22s ease-in-out infinite alternate;
}
@keyframes aurora {
  from { transform: translate3d(-3%, -2%, 0) scale(1); opacity: .55; }
  to { transform: translate3d(4%, 3%, 0) scale(1.14); opacity: .9; }
}
:root[data-theme="light"] body::before { opacity: .45; }

/* --------------------------------------------------------------- buttons */
.btn, .icon-btn, .act, .text-btn, .seg-btn, .play-btn, .tabs .tab {
  transition: transform .22s var(--spring), background .18s, color .18s, box-shadow .22s var(--glide), opacity .18s;
}
.btn { box-shadow: var(--lift-1); }
.btn:active { transform: translateY(1px) scale(.985); box-shadow: var(--lift-1); }
.icon-btn:active, .act:active, .text-btn:active { transform: scale(.92); }
.play-btn { box-shadow: 0 10px 26px -12px rgba(255, 255, 255, .5), var(--lift-1); }
.play-btn:active { transform: translateY(0) scale(.94); }

/* Icons pop as they change: play to pause, shuffle, skip. */
.play-btn svg, .mini .icon-btn svg, .np-controls .icon-btn svg, .tabs .tab.active .ico svg { animation: iconPop .32s var(--spring) both; }
@keyframes iconPop { from { transform: scale(.55) rotate(-12deg); opacity: 0; } }
@keyframes spinOnce { from { transform: rotate(0); } to { transform: rotate(180deg); } }
@keyframes bob { 30% { transform: translateY(-3px); } 60% { transform: translateY(1px); } }
@keyframes shake { 25% { transform: rotate(-12deg); } 60% { transform: rotate(9deg); } }

/* -------------------------------------------------------------- surfaces */
.join-card, .recent, .card, .now-card, .np-next, .dialog, .upload-item, .section-head, .lib-bar { box-shadow: var(--lift-2); }
.join-card { box-shadow: var(--lift-3); }



/* Panels lean towards your finger or pointer (angles come from a small script). */
.tilting { transition: transform .1s linear !important; }

.recent-row { transition: transform .22s var(--spring), background .18s, box-shadow .22s var(--glide); }
.recent-row:active { transform: translateY(0) scale(.995); }

.now-card { transition: transform .28s var(--spring), background .2s, box-shadow .28s var(--glide); }
.now-card:active { transform: scale(.99); }

/* ------------------------------------------------------------------ tabs */
.tabs { position: relative; }
.tabs .tab.active { background: color-mix(in srgb, var(--text) 6%, transparent); box-shadow: none; }
/* One indicator that slides across, instead of three separate underlines. */
.tabs::after {
  content: ""; position: absolute; bottom: 0; left: 0; height: 2px; width: calc(100% / 3);
  background: linear-gradient(90deg, transparent, var(--text), transparent);
  transform: translateX(calc(var(--tab-i, 0) * 100%));
  transition: transform .42s var(--spring);
}

.tab-page.active { animation: pageIn .42s var(--glide) both; }
@keyframes pageIn {
  from { opacity: 0; transform: perspective(900px) translate3d(0, 14px, -40px) rotateX(5deg); }
  to { opacity: 1; transform: none; }
}

/* ----------------------------------------------------------------- lists */

.row { transition: transform .2s var(--spring), background .18s, box-shadow .2s var(--glide); }
.row:active { transform: scale(.995); }
.row.playing { box-shadow: inset 2px 0 0 var(--play); }
.cover { transition: transform .35s var(--spring), box-shadow .35s var(--glide); box-shadow: var(--lift-1); }

/* The artwork of the playing song breathes. */
.mini.playing #miniCover { animation: breathe 3.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.05); } }

/* A sweep of light while a room loads, instead of a blink. */
.skel .cover, .cover.skel, .skel .sk {
  opacity: 1;
  background: linear-gradient(100deg, var(--bg-3) 20%, color-mix(in srgb, var(--text) 10%, var(--bg-3)) 42%, var(--bg-3) 64%);
  background-size: 300% 100%;
  animation: shimmer 1.5s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -150% 0; } }

/* ---------------------------------------------------------------- player */
.mini { box-shadow: 0 -20px 40px -24px rgba(0, 0, 0, 1); }
.mini-bar { background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--accent) 65%, var(--text))); box-shadow: 0 0 12px -2px color-mix(in srgb, var(--accent) 60%, transparent); }

.np-art { transition: transform .5s var(--glide), box-shadow .5s var(--glide); box-shadow: var(--shadow), 0 40px 80px -40px color-mix(in srgb, var(--np-color) 90%, transparent); }
.np.open.playing .np-art { animation: floatArt 7s ease-in-out infinite; } /* only while it's on screen */
/* A glass edge: light along the top, shade at the bottom. Black and white only. */
.np-art::after, .cover::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(150deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 38%, rgba(0, 0, 0, 0) 64%, rgba(0, 0, 0, .3));
}
@keyframes floatArt {
  0%, 100% { transform: translateY(0) rotateX(0) rotateY(0); }
  33% { transform: translateY(-8px) rotateX(2.5deg) rotateY(-3deg); }
  66% { transform: translateY(4px) rotateX(-2deg) rotateY(3deg); }
}
.np.open .np-info > * { animation: riseIn .5s var(--glide) both; }
.np.open .np-info > *:nth-child(2) { animation-delay: .06s; }
.np.open .np-info > *:nth-child(3) { animation-delay: .12s; }
.np.open .np-info > *:nth-child(4) { animation-delay: .18s; }
@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } }

/* -------------------------------------------------------------- overlays */
.sheet { box-shadow: var(--lift-3); transition: transform .34s var(--spring); }
.sheet-backdrop, .dialog-backdrop { -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fadeIn .25s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
.dialog { animation: dialogIn .34s var(--spring) both; transform-origin: 50% 60%; }
@keyframes dialogIn { from { opacity: 0; transform: perspective(800px) translateY(18px) scale(.94) rotateX(8deg); } }
.toast { animation: toastIn .34s var(--spring) both; box-shadow: var(--lift-2); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } }
.dot.ok { animation: pulseRing 2.4s ease-out infinite; }
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--play) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 7px transparent; }
}
.switch { transition: background .25s var(--glide); }
.switch::after { transition: transform .28s var(--spring), background .2s; }
.switch:checked::after { transform: translateX(16px) scale(1.05); }
.field input, .search input { transition: box-shadow .25s var(--glide), border-color .25s, transform .25s var(--spring); }
.field input:focus, .search input:focus { transform: translateY(-1px); }
.tag, .badge.on { box-shadow: 0 0 14px -6px color-mix(in srgb, var(--play) 70%, transparent); }

/* ---------------------------------------------------------------- ripple */
/* A circle of light spreads from wherever you touched. */
.btn, .act, .icon-btn, .chip, .tabs .tab, .row, .recent-main, .play-btn, .text-btn { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, color-mix(in srgb, var(--text) 26%, transparent), transparent 70%);
  transform: scale(0); opacity: .9; animation: ripple .6s var(--glide) forwards;
}
.btn.primary .ripple { background: radial-gradient(circle, rgba(0, 0, 0, .22), transparent 70%); }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
/* Content sits above the ripple. Not the ripple itself: made "relative", it took up real space,
   so a touched row grew ~500px (songs vanished while scrolling, the list jumped at its end)
   and touched buttons ballooned. */
.row > :not(.ripple), .btn > :not(.ripple), .act > :not(.ripple), .chip > :not(.ripple) { position: relative; z-index: 1; }

/* ------------------------------------------------------- playing effects */
/* A slow band of light drifts across the card of the song that's playing. */
body.playing .now-card { position: relative; overflow: hidden; }
body.playing .now-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--text) 9%, transparent) 50%, transparent 65%);
  transform: translateX(-120%); animation: sweep 5.5s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-120%); } 55%, 100% { transform: translateX(120%); } }
body.playing .mini-bar { background-size: 200% 100%; animation: flow 3.5s linear infinite; }
@keyframes flow { to { background-position: -200% 0; } }
body.playing .eq { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--play) 65%, transparent)); }
.row.playing { animation: nowGlow 3.4s ease-in-out infinite; }
@keyframes nowGlow {
  0%, 100% { box-shadow: inset 2px 0 0 var(--play); }
  50% { box-shadow: inset 3px 0 0 var(--play), 0 0 18px -10px color-mix(in srgb, var(--play) 80%, transparent); }
}

/* The small artwork turns over when the song changes. */
.mini #miniCover.swap, .mini.playing #miniCover.swap { animation: flipArt .55s var(--glide); }
@keyframes flipArt { from { transform: perspective(600px) rotateY(-90deg) scale(.85); opacity: .3; } }
.mini-row { perspective: 600px; }

/* The big sync number flips over when it changes. */
#syncBig.pop { animation: numPop .45s var(--spring); }
@keyframes numPop {
  from { transform: perspective(400px) translateY(-42%) rotateX(70deg); opacity: .2; }
  to { transform: none; opacity: 1; }
}
.sync-num { perspective: 400px; }

/* The top bar gains an edge once the page is scrolled under it. */
.topbar { transition: box-shadow .3s var(--glide), background .3s; }
#room.scrolled .topbar { box-shadow: 0 14px 30px -24px rgba(0, 0, 0, 1), 0 1px 0 var(--line-soft); }

/* ----------------------------------------------------------------- chips */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.chips-label { margin: 14px 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); }
.chips-note { margin-top: 10px; line-height: 1.6; }
.chip {
  /* A finger needs about 44px; anything smaller gets missed or read as a scroll. */
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
  background: var(--field); border: 1px solid var(--line-soft); color: var(--text-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  transition: transform .22s var(--spring), background .2s, color .2s, border-color .2s, box-shadow .25s var(--glide);
}
.chip svg { width: 14px; height: 14px; }
.chip:active { transform: scale(.94); }
.chip.on {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: var(--ring);
}
.chip.on svg { color: var(--accent); animation: pulseIcon 2.6s ease-in-out infinite; }
@keyframes pulseIcon { 50% { transform: scale(1.14); } }

/* Each person's line is coloured by how they're doing, not left grey. */
.people .who span.good-t { color: var(--play); }
.people .who span.ok-t { color: var(--warn); }
.people .who span.bad-t { color: var(--bad); }
.people .who span.dim-t { color: var(--text-3); }
.people li { transition: background .2s; border-radius: 10px; }

/* --------------------------------------------------- small touches more */
@keyframes nudge { 40% { transform: translateY(-2px); } 70% { transform: translateY(1px); } }
.vol-range::-webkit-slider-thumb, .range::-webkit-slider-thumb { transition: transform .18s var(--spring), box-shadow .2s; }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.35); }
.avatar { transition: transform .3s var(--spring); }
.upload-item { animation: riseIn .4s var(--glide) both; }
.upload-item.done .bar i { box-shadow: 0 0 12px -3px color-mix(in srgb, var(--play) 80%, transparent); }
.empty-lib h4 { animation: riseIn .5s var(--glide) both; }
.tabs .tab.active { animation: tabPress .4s var(--spring); }
@keyframes tabPress { from { transform: scale(.94); } }
.room-code:active { transform: scale(.96); }
.np-top, .np-controls { animation: riseIn .45s var(--glide) both; }

/* Anyone who asks their phone for less movement gets a calm, still app. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .06s !important;
  }
}

/* Hover effects only where there is a real mouse. On a touchscreen the browser leaves
   "hover" stuck on whatever you tapped, which made buttons look swollen for a second. */
@media (hover: hover) and (pointer: fine) {
  /* Depth that only pays off with a pointer. */
  .home-wrap { perspective: 1200px; }
  main { perspective: 1000px; }
  .list { perspective: 700px; }
  .np-body { perspective: 1400px; }
  .join-card, .recent-row, .now-card, .np-next, .cover, .np-art { transform-style: preserve-3d; }
  .btn:hover { transform: translateY(-1px); box-shadow: var(--lift-2); }
  .btn.primary:hover { box-shadow: 0 10px 30px -14px rgba(255, 255, 255, .45); opacity: 1; }
  .btn.create:hover { box-shadow: var(--ring); }
  .play-btn:hover { transform: translateY(-2px) scale(1.06); }
  #shuffleBtn:hover svg, #shuffleAllBtn:hover svg, .theme-btn:hover svg { animation: spinOnce .55s var(--glide); }
  #uploadBtn:hover svg { animation: bob .6s var(--spring); }
  .act.danger:hover svg, .text-btn.danger-text:hover svg { animation: shake .45s; transform-origin: 50% 80%; }
  .recent-row:hover { transform: translateY(-2px); box-shadow: var(--lift-2); }
  .now-card:hover { transform: translateY(-2px); box-shadow: var(--lift-3); }
  .row:hover { transform: translateX(2px); }
  .row:hover .cover, .now-card:hover .cover { transform: translateZ(14px) rotateY(-10deg) scale(1.04); box-shadow: var(--lift-2); }
  .chip:hover { color: var(--text); transform: translateY(-1px); box-shadow: var(--lift-2); }
  .people li:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
  .handle:hover svg { animation: nudge .5s var(--spring); }
  .search input:focus + .search-ico, .search:focus-within .search-ico { color: var(--accent); }
  .people li:hover .avatar { transform: scale(1.1) rotate(-4deg); }
  .status-btn:hover { transform: translateY(-1px); box-shadow: var(--lift-2); }
}

/* On phones, keep only motion that answers a touch. Effects that run forever cost battery
   and compositing work every single frame, and a busy phone is a phone that drifts. */
@media (hover: none), (pointer: coarse) {
  body::before { animation: none; opacity: .75; }
  .mini.playing #miniCover { animation: none; }
  body.playing .now-card::after { display: none; }
  .row.playing { animation: none; box-shadow: inset 2px 0 0 var(--play); }
  .np.open.playing .np-art { animation: none; }
  /* A tap leaves "hover" stuck on what was tapped, which kept these buttons enlarged. */
  .row .acts .icon-btn:hover:not(:active), .play-btn:hover:not(:active),
  .mini .icon-btn:hover:not(:active), .np-controls .icon-btn:hover:not(:active) { transform: none; }
}
