/* Full-screen vinyl player */

.fp {
  --size: min(84vw, 46vh, 420px);
  position: fixed; inset: 0; z-index: 50; overflow-x: clip;
  display: flex; flex-direction: column;
  padding: 6px var(--gutter) calc(16px + var(--safe-b));
  background: var(--bg);
  /* opens by rising and fading in while the record flies out of the mini player (vinyl.js fly()) */
  opacity: 0;
  transform: translateY(6%);
  transition: opacity .5s var(--ease-io), transform .56s var(--ease-io), visibility 0s linear .56s;
  visibility: hidden;
  overflow: hidden;
}
.fp.is-open { opacity: 1; transform: none; visibility: visible; transition: opacity .44s var(--ease-io), transform .56s var(--ease-io), visibility 0s; }

.fp__top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 48px; flex: none; }
.fp__top > [data-close] { justify-self: start; }
.fp__end { justify-self: end; display: flex; }
/* "Now playing", and under it a marker while the sleep timer or 45 rpm is on (tap to change) */
.fp__head { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; }
.fp__marker { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px; background: var(--surface);
  font: 600 11.5px/1 var(--font-sans); font-variant-numeric: tabular-nums; color: var(--accent-text); white-space: nowrap; }
.fp__marker[hidden] { display: none; }
.fp__marker.is-busy { color: var(--text-2); }
.fp__marker.is-busy span { animation: marker-busy 1.2s var(--ease-io) infinite; }
@keyframes marker-busy { 50% { opacity: .45; } }
.fp__marker .ic { width: 12px; height: 12px; }
.fp__marker i { font-style: normal; color: var(--text-3); }
.fp__kicker { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); }

/* touch-action none: a circular drag on the record must never turn into a browser pan (pointercancel) */
.fp__stage { position: relative; flex: 1; min-height: calc(var(--size) + 24px); touch-action: none; cursor: grab; }
.fp.is-scrubbing .fp__stage { cursor: grabbing; }

/* time bubble while the record is turned by hand */
.scrub { position: absolute; left: 50%; top: 0; z-index: 2; display: flex; align-items: baseline; gap: 8px; padding: 7px 12px;
  border-radius: var(--r-md); background: var(--toast); color: var(--on-toast); font-variant-numeric: tabular-nums; white-space: nowrap;
  opacity: 0; transform: translate(-50%, 6px); transition: opacity .25s var(--ease-io), transform .3s var(--ease-io); pointer-events: none; }
.scrub__time { font: 600 17px/1 var(--font-serif); }
.scrub__delta { font-size: 13px; opacity: .75; }
.fp.is-scrubbing .scrub { opacity: 1; transform: translate(-50%, -4px); }

/* ---------- record ---------- */

.record {
  position: absolute; inset: 0; margin: auto;
  width: var(--size); height: var(--size);
  border-radius: 50%;
  box-shadow: 0 14px 36px var(--shadow);
  will-change: transform;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
:root[data-mode="dark"] .record { box-shadow: 0 14px 36px var(--shadow), 0 0 0 1px rgba(255, 240, 220, .06); }
.record__spin { position: absolute; inset: 0; border-radius: 50%; }
.record__disc, .record__sheen { position: absolute; inset: 0; width: 100%; height: 100%; }
.record__sheen { pointer-events: none; }

.disc__body { fill: var(--vinyl); }
.disc__edge { fill: none; stroke: rgba(255, 255, 255, .12); stroke-width: .6; }
.disc__groove { fill: none; stroke: var(--groove); stroke-width: .5; }
.disc__gap { fill: none; stroke: rgba(0, 0, 0, .55); stroke-width: 1.4; }
.disc__arc { fill: none; stroke: var(--groove-strong); stroke-width: .9; stroke-linecap: round; }
.sheen { fill: var(--sheen); }

.record__label {
  position: absolute; inset: 31%;
  border-radius: 50%; overflow: hidden;
  background: var(--bordeaux);
  box-shadow: 0 0 0 2px var(--bordeaux), 0 0 0 3px rgba(0, 0, 0, .4);
  display: grid; place-items: center;
}
.record__label img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.record__blank { font: 500 13px/1 var(--font-serif); color: var(--white); }
.record__hole {
  position: absolute; left: 50%; top: 50%;
  width: 3.4%; height: 3.4%; margin: -1.7% 0 0 -1.7%;
  border-radius: 50%; background: var(--bg);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .35);
}
.fp.is-loading .record__label img { animation: pulse 1.1s ease-in-out infinite; }

/* ---------- sleeve: a first listen comes out of it (vinyl.js unsleeve) ---------- */

.sleeve { position: absolute; inset: 0; z-index: 1; margin: auto; width: calc(var(--size) * 1.04); height: calc(var(--size) * 1.04);
  border-radius: 4px; overflow: hidden; background: var(--bordeaux); box-shadow: 0 16px 40px var(--shadow);
  display: grid; place-items: center; pointer-events: none; will-change: transform; }
.fp.is-turntable .sleeve { right: calc(var(--size) * .34); } /* the same centre as the record on the platter */
.sleeve img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* printed edge of the cardboard and its open side, where the record comes out */
.sleeve::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), inset 0 0 0 5px rgba(0, 0, 0, .12); }
.sleeve__slot { position: absolute; right: 0; top: 4%; bottom: 4%; width: 4px; background: rgba(0, 0, 0, .38); border-radius: 2px 0 0 2px; }
.sleeve__brand { font: 600 calc(var(--size) * .12)/1 var(--font-serif); letter-spacing: .04em; color: #F3E7D3; }

/* ---------- info ---------- */

.fp__info { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex: none; }
.fp__titles { flex: 1; min-width: 0; }
.fp__title { font: 600 24px/1.2 var(--font-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp__artist { display: block; max-width: 100%; font-size: 15px; color: var(--text-2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: left; text-decoration: underline dotted var(--text-3); text-underline-offset: 4px; }
.fp__artist:active { color: var(--text); }
.fp__like { color: var(--text-2); }
.fp__like.is-on { color: var(--accent-text); }
.fp__like.is-on .ic { animation: like-pop .3s var(--ease); }
@keyframes like-pop { 50% { transform: scale(1.25); } }

/* ---------- progress ---------- */

.progress { margin-top: 18px; flex: none; }
.progress__bar { position: relative; height: 24px; cursor: pointer; touch-action: none; }
.progress__bar::before { content: ''; position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: var(--line); }
.progress__fill { position: absolute; left: 0; right: 0; top: 10px; height: 4px; border-radius: 2px; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); }
/* the knob rides on a full-width layer moved by transform: animating `left` would relayout on every tick */
.progress__thumb { position: absolute; inset: 0; transform: translateX(calc(var(--p, 0) * 100%)); pointer-events: none; }
.progress__knob { position: absolute; top: 6px; left: 0; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--accent); transition: transform .15s; }
.progress.is-drag .progress__knob { transform: scale(1.5); }
.progress__times { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; margin-top: 2px; }
.fp.is-loading .progress__fill { animation: pulse 1s ease-in-out infinite; }

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

.controls { display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center; justify-items: center; margin-top: 10px; flex: none; }
.controls .icon-btn { width: 48px; height: 48px; position: relative; color: var(--text); }
.controls .icon-btn--lg .ic { width: 30px; height: 30px; }
.controls [data-shuffle], .controls [data-repeat] { color: var(--text-3); }
.controls .is-on { color: var(--accent-text) !important; }
.controls .is-on::after { content: ''; position: absolute; bottom: 4px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.play-btn { width: 70px; height: 70px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; transition: transform .15s; }
.play-btn .ic { width: 32px; height: 32px; }
.play-btn:active { transform: scale(.94); background: var(--accent-press); }

.fp__extra { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 14px; flex: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-md); font-size: 13px; font-weight: 500; color: var(--text-2); min-width: 0; }
.pill span { white-space: nowrap; }
.fp__extra > .pill { flex-shrink: 0; max-width: 100%; }
.pill .ic { width: 18px; height: 18px; }
.pill:active { background: var(--surface); }
.pill--icon { width: 38px; padding: 0; justify-content: center; flex: none; }
.pill[hidden] { display: none; }
/* four buttons in the row (lyrics found): a little tighter so they fit a 375 px phone */
.fp__extra:has(> [data-lyrics]:not([hidden])) { gap: 8px; }
.fp__extra:has(> [data-lyrics]:not([hidden])) .pill:not(.pill--icon) { padding: 0 11px; gap: 6px; }

/* ---------- idle: interface fades away, the record drifts to the centre ---------- */

.fp__top, .fp__info, .progress, .controls, .fp__extra { transition: opacity .45s var(--ease-io), transform .5s var(--ease-io); }
.fp__stage { transition: transform .6s var(--ease-io); }
.fp.is-idle .fp__top, .fp.is-idle .fp__info, .fp.is-idle .progress, .fp.is-idle .controls, .fp.is-idle .fp__extra {
  opacity: 0; pointer-events: none; transition: opacity .8s var(--ease-io), transform 1s var(--ease-io); }
.fp.is-idle .fp__top { transform: translateY(-16px); }
.fp.is-idle .fp__info { transform: translateY(14px); transition-delay: .06s; }
.fp.is-idle .progress { transform: translateY(20px); transition-delay: .12s; }
.fp.is-idle .controls { transform: translateY(26px); transition-delay: .18s; }
.fp.is-idle .fp__extra { transform: translateY(32px); transition-delay: .24s; }
.fp.is-idle .fp__stage { transform: translateY(var(--idle-dy, 0)) scale(var(--idle-scale, 1.12)); transition: transform 1.2s var(--ease-io) .15s; }
.fp.is-idle { cursor: none; }

/* ---------- turntable mode (Settings → Customization) ----------
   The deck stays put behind the record: the record itself is still the only thing swiped, turned and swapped.
   Geometry in units of --size (S, the record's diameter): plinth 1.5 S × 1.16 S, record shifted .17 S to the left,
   tonearm pivot at (+.58 S, −.38 S) from the centre of the stage. */
.deck { position: absolute; inset: 0; display: none; pointer-events: none; }
.fp.is-turntable { --size: min(60vw, 40vh, 300px); }
.fp.is-turntable .deck { display: block; }
.fp.is-turntable .fp__stage { min-height: calc(var(--size) * 1.16 + 20px); }
.fp.is-turntable .record { right: calc(var(--size) * .34); box-shadow: 0 3px 10px rgba(0, 0, 0, .45); }
.deck__plinth { position: absolute; left: 50%; top: 50%; width: calc(var(--size) * 1.5); height: calc(var(--size) * 1.16);
  margin: calc(var(--size) * -.58) 0 0 calc(var(--size) * -.75); border-radius: 12px; background: var(--dk-body);
  box-shadow: 0 16px 40px var(--shadow), inset 0 0 0 1px var(--dk-edge); }
.deck__plinth::before { content: ''; position: absolute; inset: calc(var(--size) * .035); border-radius: 8px; background: var(--dk-panel); }
.deck__knob { position: absolute; left: calc(var(--size) * .08); bottom: calc(var(--size) * .08); width: calc(var(--size) * .1); height: calc(var(--size) * .1);
  border-radius: 50%; background: var(--dk-platter); box-shadow: 0 0 0 calc(var(--size) * .008) var(--dk-metal); }
.deck__light { position: absolute; left: calc(var(--size) * .22); bottom: calc(var(--size) * .115); width: calc(var(--size) * .028); height: calc(var(--size) * .028);
  border-radius: 50%; background: var(--dk-led); transition: background .4s; }
.fp.is-arm-down .deck__light { background: var(--dk-led-on); }
.deck__speed { position: absolute; right: calc(var(--size) * .09); bottom: calc(var(--size) * .07); font: 600 calc(var(--size) * .05)/1 var(--font-sans);
  color: var(--dk-text); letter-spacing: .06em; }
.deck__platter { position: absolute; left: calc(50% - var(--size) * .17); top: 50%; width: calc(var(--size) * 1.04); height: calc(var(--size) * 1.04);
  margin: calc(var(--size) * -.52) 0 0 calc(var(--size) * -.52); border-radius: 50%; background: var(--dk-platter);
  box-shadow: 0 0 0 calc(var(--size) * .012) var(--dk-metal), 0 6px 18px rgba(0, 0, 0, .45); }
/* the arm turns around its pivot: a zero-size box placed on the pivot, parts hanging from it */
.deck__arm { position: absolute; z-index: 2; left: calc(50% + var(--size) * .58); top: calc(50% - var(--size) * .38); width: 0; height: 0;
  transform: rotate(var(--arm, 8deg)); transition: transform 1.1s cubic-bezier(.45, 0, .25, 1); }
.deck__arm span { position: absolute; display: block; }
.arm__base { left: calc(var(--size) * -.085); top: calc(var(--size) * -.085); width: calc(var(--size) * .17); height: calc(var(--size) * .17);
  border-radius: 50%; background: var(--dk-dark); box-shadow: 0 0 0 calc(var(--size) * .012) var(--dk-metal), 0 4px 10px rgba(0, 0, 0, .4); }
.arm__weight { left: calc(var(--size) * -.05); top: calc(var(--size) * -.21); width: calc(var(--size) * .1); height: calc(var(--size) * .12);
  border-radius: 4px; background: var(--dk-dark); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.arm__tube { left: calc(var(--size) * -.011); top: 0; width: calc(var(--size) * .022); height: calc(var(--size) * .82); border-radius: 99px; background: var(--dk-tube);
  box-shadow: 2px 3px 6px rgba(0, 0, 0, .35); }
.arm__head { left: calc(var(--size) * -.036); top: calc(var(--size) * .8); width: calc(var(--size) * .072); height: calc(var(--size) * .14); border-radius: 3px;
  background: var(--dk-dark); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 2px 3px 6px rgba(0, 0, 0, .35); }

@media (max-height: 640px) {
  .fp { --size: min(76vw, 40vh); }
  .fp.is-turntable { --size: min(58vw, 34vh); }
  .fp__title { font-size: 20px; }
  .progress { margin-top: 10px; }
  .play-btn { width: 60px; height: 60px; }
  .fp__extra { margin-top: 8px; }
}

@media (min-width: 720px) {
  .fp { padding-left: calc(50% - 340px); padding-right: calc(50% - 340px); }
}

/* ---------- landscape phone: the record on the left, everything else stacked on the right ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .fp { --size: min(74vh, 42vw); display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); grid-template-rows: repeat(5, auto);
    align-content: center; column-gap: 28px;
    padding: 6px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(8px + var(--safe-b)) max(var(--gutter), env(safe-area-inset-left, 0px)); }
  .fp.is-turntable { --size: min(62vh, 27vw); }
  .fp__stage, .fp.is-turntable .fp__stage { grid-column: 1; grid-row: 1 / -1; min-height: calc(var(--size) + 16px); }
  .fp.is-turntable .fp__stage { min-height: calc(var(--size) * 1.16 + 16px); }
  .fp__top, .fp__info, .progress, .controls, .fp__extra { grid-column: 2; }
  .fp__top { height: 40px; }
  .fp__info { margin-top: 0; }
  .fp__title { font-size: 20px; }
  .progress { margin-top: 8px; }
  .controls { margin-top: 2px; }
  .play-btn { width: 56px; height: 56px; }
  .play-btn .ic { width: 26px; height: 26px; }
  .fp__extra { margin-top: 8px; }
  .scrub { top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .fp, .fp.is-open { transform: none; transition: opacity .3s, visibility 0s linear .3s; }
  .deck__arm { transition: none; }
  .fp.is-idle .fp__stage { transform: none; }
  .fp.is-idle :is(.fp__top, .fp__info, .progress, .controls, .fp__extra) { transform: none; }
}

/* ---------- tape deck view (Settings → Player → Tape deck) ----------
   --size is the cassette's width (S); the cassette is .63 S tall. The deck around it: 1.24 S × 1.06 S, its bay centred on
   the stage (so the cassette sits where a record would), the bay's centre .49 S below the deck's top edge. */
.recorder { position: absolute; inset: 0; display: none; pointer-events: none; }
.fp.is-cassette { --size: min(70vw, 38vh, 330px); }
.fp.is-cassette .recorder { display: block; }
.fp.is-cassette .fp__stage { min-height: calc(var(--size) * 1.14 + 16px); }

.recorder > * { position: absolute; }
.recorder::before { content: ''; position: absolute; left: 50%; top: 50%; width: calc(var(--size) * 1.24); height: calc(var(--size) * 1.06);
  margin: calc(var(--size) * -.49) 0 0 calc(var(--size) * -.62); border-radius: 10px; background: var(--rc-body);
  box-shadow: 0 16px 40px var(--shadow), inset 0 0 0 1px var(--rc-edge); }
.rec__top { left: 50%; top: 50%; width: calc(var(--size) * 1.14); height: calc(var(--size) * .1);
  margin: calc(var(--size) * -.465) 0 0 calc(var(--size) * -.57); display: flex; align-items: center; gap: calc(var(--size) * .03); }
.rec__counter { padding: calc(var(--size) * .008) calc(var(--size) * .018); border-radius: 3px; background: var(--rc-counter); color: var(--rc-digits);
  font: 600 calc(var(--size) * .045)/1 ui-monospace, 'SFMono-Regular', Menlo, monospace; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.rec__brand { flex: 1; font: 600 calc(var(--size) * .042)/1 var(--font-serif); letter-spacing: .08em; color: var(--rc-text); white-space: nowrap; }
.rec__brand small { margin-left: .5em; font: 600 .7em/1 var(--font-sans); letter-spacing: .2em; opacity: .75; }
.rec__speed { font: 600 calc(var(--size) * .034)/1 var(--font-sans); color: var(--rc-text); letter-spacing: .04em; white-space: nowrap; }
.rec__led { width: calc(var(--size) * .026); height: calc(var(--size) * .026); border-radius: 50%; background: var(--rc-led); transition: background .3s; }
.fp.is-rolling .rec__led { background: var(--rc-led-on); }
/* the bay the cassette sits in */
.rec__bay { left: 50%; top: 50%; width: calc(var(--size) * 1.1); height: calc(var(--size) * .74); margin: calc(var(--size) * -.37) 0 0 calc(var(--size) * -.55);
  border-radius: 6px; background: var(--rc-bay); box-shadow: inset 0 0 0 calc(var(--size) * .012) var(--rc-panel); }
/* the piano keys: the play key stays down while the music plays */
.rec__keys { left: 50%; top: 50%; width: calc(var(--size) * 1.1); height: calc(var(--size) * .13); margin: calc(var(--size) * .42) 0 0 calc(var(--size) * -.55);
  display: grid; grid-template-columns: repeat(6, 1fr); gap: calc(var(--size) * .014); }
.rec__key { display: grid; place-items: center; border-radius: 3px 3px 5px 5px; background: var(--rc-key); color: var(--rc-key-text);
  box-shadow: 0 calc(var(--size) * .014) 0 var(--rc-key-down); transition: transform .12s, box-shadow .12s, background .12s; }
.rec__key svg { width: calc(var(--size) * .05); height: calc(var(--size) * .05); fill: currentColor; }
.rec__key[data-k="rec"] { color: #C8261E; }
.fp.is-rolling .rec__key[data-k="play"], .fp.is-scrubbing .rec__key[data-k="ff"] {
  transform: translateY(calc(var(--size) * .012)); box-shadow: 0 calc(var(--size) * .002) 0 var(--rc-key-down); background: var(--rc-key-down); }

/* the cassette itself (vinyl.js makeCassette): the shell drawn in SVG, the label written in HTML over it */
.record.cassette { height: calc(var(--size) * .63); border-radius: calc(var(--size) * .035); box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
:root[data-mode="dark"] .record.cassette { box-shadow: 0 6px 16px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 240, 220, .06); }
.cassette__body { position: absolute; inset: 0; width: 100%; height: 100%; }
.cs__shell { fill: var(--tp-shell); stroke: var(--tp-edge); stroke-width: 1; }
.cs__label { fill: var(--tp-label); }
.cs__band { fill: var(--tp-band); }
.cs__window { fill: var(--tp-window); stroke: rgba(0, 0, 0, .35); stroke-width: 1; }
.cs__pack { fill: var(--tp-tape); }
.cs__reel { transform-box: fill-box; transform-origin: center; }
.cs__hub { fill: var(--tp-hub); }
.cs__core { fill: var(--tp-window); }
.cs__tooth { fill: var(--tp-hub); }
.cs__foot { fill: var(--tp-shell); stroke: var(--tp-edge); stroke-width: 1; }
.cs__hole { fill: rgba(0, 0, 0, .55); }
.cs__screw { fill: var(--tp-screw); }
.cassette__title { position: absolute; left: 10%; right: 10%; top: 8.6%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font: italic 500 calc(var(--size) * .052)/1.1 var(--font-serif); color: var(--tp-ink); pointer-events: none; }
.cassette__art { position: absolute; left: 9.5%; top: 29%; width: 17%; height: 30%; overflow: hidden; border-radius: 2px; background: var(--tp-band); pointer-events: none; }
.cassette__art img { width: 100%; height: 100%; object-fit: cover; }
.cassette__side { position: absolute; right: 10%; top: 31%; font: 700 calc(var(--size) * .11)/1 var(--font-serif); color: var(--tp-band); pointer-events: none; }
.fp.is-loading .cassette__art img { animation: pulse 1.1s ease-in-out infinite; }

/* the case a new cassette comes out of (vinyl.js uncase) */
.sleeve.is-case { width: calc(var(--size) * 1.06); height: calc(var(--size) * .7); border-radius: 5px; background: var(--tp-shell); }
.sleeve.is-case::after { box-shadow: inset 0 0 0 calc(var(--size) * .018) rgba(255, 255, 255, .28), inset 0 0 0 calc(var(--size) * .022) rgba(0, 0, 0, .18); }
.sleeve__hinge { position: absolute; left: 0; right: 0; top: 0; height: 9%; background: rgba(255, 255, 255, .22); }
.sleeve.is-case .sleeve__brand { font-size: calc(var(--size) * .1); }

@media (max-height: 640px) {
  .fp.is-cassette { --size: min(68vw, 33vh); }
}
@media (orientation: landscape) and (max-height: 520px) {
  .fp.is-cassette { --size: min(56vh, 30vw); }
  .fp.is-cassette .fp__stage { min-height: calc(var(--size) * 1.14 + 16px); }
}
