/* ============================================================
   player.css — the cassette player, bottom right, where it belongs
   ============================================================ */

.player {
  position: fixed;
  right: clamp(0.7rem, 2vw, 1.6rem);
  bottom: clamp(0.7rem, 2vw, 1.6rem);
  z-index: 50;
  width: min(17.5rem, calc(100vw - 1.6rem));
  padding: 0.85rem 0.9rem 0.7rem;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px),
    linear-gradient(170deg, #3b3832 0%, #2a2823 55%, #1d1b18 100%);
  border: 1px solid #000;
  border-radius: 8px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.1) inset,
    0 22px 44px -20px rgba(0,0,0,0.9);
  color: #e3d8bf;
  transition: transform 0.55s var(--ease-out), opacity 0.4s;
}

.player.is-collapsed {
  transform: translateY(calc(100% - 2.3rem));
}

.player__toggle {
  position: absolute;
  top: 0.35rem;
  right: 0.45rem;
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: #8e8574;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.3s, transform 0.4s var(--ease-out);
}
.player__toggle:hover { color: var(--gold-bright); }
.player.is-collapsed .player__toggle { transform: rotate(180deg); }

/* ---------- cassette ---------- */

.player__tape {
  position: relative;
  height: 4.6rem;
  border-radius: 4px;
  background: linear-gradient(165deg, #d8cdb2, #bfb296 60%, #a89b7f);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.4), inset 0 2px 6px rgba(255,255,255,0.3);
  overflow: hidden;
}

.player__window {
  position: absolute;
  inset: 0.5rem 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.55rem;
  background: linear-gradient(180deg, #2e2b25, #1a1814);
  border-radius: 3px;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.9);
}

.reel {
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 2px solid #c9bda0;
  background: radial-gradient(circle, #1a1814 0 28%, #4a443a 29% 100%);
  display: grid;
  place-items: center;
}

.reel i {
  position: absolute;
  width: 2px;
  height: 0.62rem;
  background: #c9bda0;
  border-radius: 1px;
  transform-origin: 50% 50%;
}
.reel i:nth-child(1) { rotate: 0deg; }
.reel i:nth-child(2) { rotate: 60deg; }
.reel i:nth-child(3) { rotate: 120deg; }

.player.is-playing .reel { animation: spin 2.4s linear infinite; }
.player.is-playing .reel--r { animation-duration: 3.4s; }

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

/* the tape itself, stretched between the reels */
.player__window::before {
  content: "";
  position: absolute;
  left: 1.45rem;
  right: 1.45rem;
  top: 50%;
  height: 1px;
  background: #6d6453;
}

.player__label {
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.player__side {
  display: grid;
  place-items: center;
  width: 0.95rem;
  height: 0.95rem;
  border: 1px solid #6d6453;
  border-radius: 2px;
  font-family: var(--label);
  font-size: 0.52rem;
  color: #4e4738;
}

.player__cassette {
  font-family: var(--hand);
  font-size: 0.82rem;
  color: #3f3929;
  letter-spacing: 0.02em;
}

/* ---------- readout ---------- */

.player__readout {
  margin-top: 0.7rem;
  padding: 0.4rem 0.55rem;
  background: #10140f;
  border-radius: 3px;
  box-shadow: inset 0 1px 5px rgba(0,0,0,0.9), 0 0 0 1px rgba(0,0,0,0.6);
}

.marquee {
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #8ad66f;
  text-shadow: 0 0 7px rgba(138, 214, 111, 0.55);
}

/* Two copies of the title side by side, scrolled by exactly half their
   combined width, so the loop has no gap in it. */
.marquee__inner { display: inline-flex; }

.marquee__inner span { display: inline-block; padding-right: 2.4rem; }

.player.is-playing .marquee__inner {
  animation: slide 13s linear infinite;
}

@keyframes slide {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.player__artist {
  margin-top: 0.15rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: #4e7a42;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.player__controls {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.65rem;
}

.player__controls button {
  width: 2rem;
  height: 1.8rem;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #4a463d, #35322b);
  border: 1px solid #16150f;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 2px 3px rgba(0,0,0,0.5);
  color: #d9ceb3;
  font-size: 0.7rem;
  cursor: pointer;
  transition: transform 0.1s, background 0.3s, color 0.3s;
}

.player__controls button:hover { color: var(--gold-bright); }
.player__controls button:active { transform: translateY(1px); box-shadow: 0 1px 2px rgba(0,0,0,0.6) inset; }

.player__controls .is-main {
  width: 2.6rem;
  background: linear-gradient(180deg, #5d5748, #413d34);
  color: #f0e4c4;
}

.player.is-playing .is-main { color: #8ad66f; }

.player__vol {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  color: #8e8574;
  font-size: 0.7rem;
}

.player__vol input {
  -webkit-appearance: none;
  appearance: none;
  width: 4.6rem;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, #8ad66f 0 55%, #3a382f 55%);
  cursor: pointer;
}

.player__vol input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, #d9ceb3, #8e8574);
  border: 1px solid #16150f;
}

.player__vol input::-moz-range-thumb {
  width: 11px;
  height: 15px;
  border-radius: 2px;
  background: linear-gradient(180deg, #d9ceb3, #8e8574);
  border: 1px solid #16150f;
}

/* ---------- tape counter ---------- */

.player__progress {
  height: 2px;
  margin-top: 0.55rem;
  background: #16150f;
  border-radius: 1px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.8);
}

.player__progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #4e7a42, #8ad66f);
  transition: width 0.25s linear;
}

/* ---------- little VU bars ---------- */

.player__eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.85rem;
  margin-top: 0.55rem;
  opacity: 0.35;
  transition: opacity 0.4s;
}

.player.is-playing .player__eq { opacity: 1; }

.player__eq i {
  flex: 1;
  height: 12%;
  background: linear-gradient(180deg, #8ad66f, #3f6a34);
  border-radius: 1px;
}

.player.is-playing .player__eq i {
  animation: vu 0.72s var(--ease-soft) infinite alternate;
}

.player__eq i:nth-child(1) { animation-delay: 0s;    }
.player__eq i:nth-child(2) { animation-delay: 0.09s; }
.player__eq i:nth-child(3) { animation-delay: 0.22s; }
.player__eq i:nth-child(4) { animation-delay: 0.05s; }
.player__eq i:nth-child(5) { animation-delay: 0.31s; }
.player__eq i:nth-child(6) { animation-delay: 0.16s; }
.player__eq i:nth-child(7) { animation-delay: 0.26s; }

@keyframes vu {
  from { height: 12%; }
  to   { height: 100%; }
}

/* ---------- couldn't reach the soundfont ---------- */

.player.is-error .player__readout { box-shadow: inset 0 0 0 1px rgba(197,88,76,0.5); }
.player.is-error .marquee { color: #d08a7e; text-shadow: none; }
.player.is-error .player__artist { color: #a0675e; }

@media (prefers-reduced-motion: reduce) {
  .player.is-playing .reel,
  .player.is-playing .marquee__inner,
  .player.is-playing .player__eq i { animation: none; }
}

/* ─────────────────────  THE "PRESS PLAY" ARROW  ──────────────────────── */

/* Biro on the desk, next to the deck. It draws itself on a moment after
   the page settles, and goes for good the first time the tape rolls.
   It lives inside .player so it is positioned against the real deck
   rather than against a guess at where the deck ended up. */

.tapehint {
  position: absolute;
  right: 100%;
  bottom: 0.3rem;
  width: 10.5rem;
  margin-right: 0.15rem;
  pointer-events: none;
  transition: opacity 0.7s var(--ease-soft);
}

/* Nothing to point at once the deck is folded away, and nothing left to
   say once the tape has actually rolled. Deliberately NOT hidden on
   .is-error: if the browser refused to autoplay off the cover button,
   pressing play by hand is the fix, so the arrow is needed most then. */
.player.is-collapsed .tapehint,
.player.has-played .tapehint { opacity: 0; }

.tapehint__label {
  margin: 0 0 0.1rem;
  padding-right: 1.4rem;
  text-align: right;
  font-family: var(--hand);
  font-size: 1.5rem;
  line-height: 1.1;
  color: rgba(232, 205, 132, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  rotate: -3deg;
  opacity: 0;
  animation: tapehint-write 0.7s var(--ease-out) 0.35s forwards;
}

.tapehint__arrow {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.tapehint__shaft,
.tapehint__barb {
  fill: none;
  stroke: rgba(232, 205, 132, 0.82);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.55));
}

/* a second pass of the pen, slightly off the first, the way a real one is */
.tapehint__shaft--ghost {
  stroke-width: 1.3;
  opacity: 0.45;
}

/* the shaft draws first, then the two flicks of the head */
.tapehint__shaft {
  stroke-dasharray: 230;
  stroke-dashoffset: 230;
  animation: tapehint-draw 1.1s var(--ease-out) 0.7s forwards;
}

.tapehint__barb {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: tapehint-draw 0.35s var(--ease-out) 1.75s forwards;
}

@keyframes tapehint-write {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes tapehint-draw {
  to { stroke-dashoffset: 0; }
}

/* On one page the deck starts folded down and sits on the foot of it, so
   there is nowhere sensible to put this. The cover mentions the tape. */
@media (max-width: 56rem) {
  .tapehint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tapehint__label { animation: none; opacity: 1; }
  .tapehint__shaft,
  .tapehint__barb { animation: none; stroke-dashoffset: 0; }
}
