/* ---------------------------------------------
   music.lowhorse.app. Tokens live in /shared/tokens.css.
   --------------------------------------------- */

:root {
  --cover: clamp(200px, min(64vw, 40vh), 420px);
  --player-h: 64px;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.has-player { padding-bottom: calc(var(--player-h) + env(safe-area-inset-bottom)); }

.music {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(20px, 5vh, 56px) 0 48px;
}

/* ---------- the shelf of covers ---------- */

.shelf {
  position: relative;
  width: 100%;
  height: var(--cover);
  flex: none;
  overflow-x: clip;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.covers {
  position: absolute;
  inset: 0;
}

.cover {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--cover);
  height: var(--cover);
  margin-left: calc(var(--cover) / -2);
  transform-origin: 50% 50%;
  cursor: pointer;
  will-change: transform, opacity;
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
  box-shadow: 0 14px 40px -18px rgba(20, 18, 11, 0.45);
}
.cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* play mark on the cover in front */
.playmark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  color: var(--ink);
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}
.playmark svg { width: 22px; height: 22px; fill: currentColor; }
.playmark .i-pause { display: none; }
.cover.is-front:hover .playmark,
.cover.is-front:focus-visible .playmark { opacity: 1; transform: none; }
.cover.is-playing .playmark .i-play { display: none; }
.cover.is-playing .playmark .i-pause { display: block; }
@media (hover: none) {
  .cover.is-front .playmark { opacity: 0.9; transform: none; }
  .cover.is-front.is-playing .playmark { opacity: 0; }
}

.nav {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: opacity 160ms ease, border-color 160ms ease;
}
.nav:hover { border-color: var(--ink-soft); }
.nav[disabled] { opacity: 0.25; cursor: default; }

/* ---------- what's in front ---------- */

.info {
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
  margin-top: clamp(22px, 4vh, 40px);
  text-align: center;
}
.info > * { transition: opacity 160ms ease, transform 160ms ease; }
.info.swap > * { opacity: 0; transform: translateY(4px); }

.count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 11px;
  color: var(--ink-soft);
}

.title {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05;
}

.meta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}

.blurb {
  margin: 14px auto 0;
  max-width: 38ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.blurb[hidden], .count[hidden] { display: none; }

.tracks {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  text-align: left;
  border-top: 1px solid var(--line);
}
.tracks li { border-bottom: 1px solid var(--line); }

.track {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 11px 6px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}
.track:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.track .n,
.track .d { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; color: var(--ink-soft); }
.track .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* now playing: the number becomes three little bars */
.track .eq { display: none; gap: 2px; align-items: flex-end; height: 11px; }
.track .eq i { width: 2px; background: var(--accent); animation: eq 900ms ease-in-out infinite; }
.track .eq i:nth-child(2) { animation-delay: -300ms; }
.track .eq i:nth-child(3) { animation-delay: -600ms; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 11px; } }
.track.is-current .t { color: var(--accent); }
.track.is-current .n { display: none; }
.track.is-current .eq { display: flex; }
.paused .track.is-current .eq i { animation-play-state: paused; }

/* ---------- player ---------- */

.player {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: calc(var(--player-h) + env(safe-area-inset-bottom));
  padding: 0 16px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: auto minmax(120px, 240px) 1fr auto;
  align-items: center;
  gap: 18px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  user-select: none;
  -webkit-user-select: none;
  animation: up 240ms ease;
}
.player[hidden] { display: none; }
@keyframes up { from { transform: translateY(100%); } }

.p-controls { display: flex; align-items: center; gap: 4px; }
.pbtn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.pbtn svg { width: 14px; height: 14px; fill: currentColor; }
.pbtn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.pbtn.big { width: 40px; height: 40px; border: 1px solid var(--line); }
.pbtn.big svg { width: 16px; height: 16px; }
.pbtn .i-pause { display: none; }
.player.is-playing .pbtn .i-play { display: none; }
.player.is-playing .pbtn .i-pause { display: block; }

.p-now { min-width: 0; }
.p-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-sub { margin-top: 3px; font-size: 10px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.p-bar {
  position: relative;
  height: 30px;
  cursor: pointer;
  touch-action: none;
}
.p-line,
.p-fill {
  position: absolute;
  left: 0;
  bottom: 9px;
  height: 1px;
}
.p-line { right: 0; background: var(--line); }
.p-fill { width: 0; height: 2px; bottom: 8.5px; background: var(--ink); }
.p-horse {
  position: absolute;
  left: 0;
  bottom: 9px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-bottom: -6px;
  fill: var(--ink);
  shape-rendering: crispEdges;
}
.p-horse .frame-b { display: none; }
.player.is-playing .p-horse .frame-a { animation: frame-a 420ms steps(1) infinite; }
.player.is-playing .p-horse .frame-b { display: inline; animation: frame-b 420ms steps(1) infinite; }
@keyframes frame-a { 50% { opacity: 0; } }
@keyframes frame-b { 0% { opacity: 0; } 50% { opacity: 1; } }

.p-time { font-size: 11px; color: var(--ink-soft); min-width: 7.5em; text-align: right; }

@media (max-width: 640px) {
  :root { --player-h: 92px; }
  .player {
    grid-template-columns: 1fr auto;
    grid-template-rows: 30px auto;
    row-gap: 4px;
    column-gap: 12px;
    padding-top: 8px;
  }
  .p-bar { grid-column: 1 / -1; grid-row: 1; }
  .p-now { grid-column: 1; grid-row: 2; }
  .p-controls { grid-column: 2; grid-row: 2; }
  .p-time { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .player.is-playing .p-horse .frame-a,
  .player.is-playing .p-horse .frame-b,
  .track .eq i { animation: none; }
}
