/* ============================================================
   SHARED PLAYER — one instance, fixed to viewport bottom
   ============================================================ */

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: var(--player-h);
  background: rgba(17, 27, 49, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line-strong);
  transform: translateY(100%);
  transition: transform var(--med) var(--ease);
  padding-bottom: env(safe-area-inset-bottom);
}
.player.is-active { transform: translateY(0); }

.player__inner {
  height: var(--player-h);
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5);
}

.player__track { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.player__art { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--ink-3); }
.player__meta { min-width: 0; }
.player__title { font-weight: 600; font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__album { font-size: 0.78rem; color: var(--mist-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player__center { display: flex; flex-direction: column; align-items: center; gap: var(--sp-1); min-width: 320px; }
.player__transport { display: flex; align-items: center; gap: var(--sp-3); }
.player__transport .icon-btn { width: 34px; height: 34px; }
.player__transport .icon-btn svg { width: 17px; height: 17px; }
.player__play {
  width: 40px; height: 40px; border-radius: 999px; background: var(--paper); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--fast) var(--ease);
}
.player__play:hover { transform: scale(1.06); }
.player__play svg { width: 17px; height: 17px; }

.player__seek { display: flex; align-items: center; gap: var(--sp-2); width: 100%; }
.player__time { font-family: var(--font-mono); font-size: 0.72rem; color: var(--mist-dim); width: 3.2em; text-align: center; }
.player__seek-bar {
  position: relative; flex: 1; height: 14px; display: flex; align-items: center; cursor: pointer;
}
.player__seek-track { position: relative; width: 100%; height: 3px; background: var(--ink-4); border-radius: 2px; overflow: visible; }
.player__seek-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--coral), var(--aqua));
  border-radius: 2px;
}
.player__seek-thumb {
  position: absolute; top: 50%; left: 0%;
  width: 11px; height: 11px; border-radius: 999px; background: var(--paper);
  transform: translate(-50%, -50%); opacity: 0; transition: opacity var(--fast) var(--ease);
  box-shadow: 0 0 0 3px var(--coral-wash);
}
.player__seek-bar:hover .player__seek-thumb { opacity: 1; }
.player__seek-input {
  position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; margin: 0;
}

.player__right { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-3); }
.player__volume { display: flex; align-items: center; gap: var(--sp-2); width: 130px; }
.player__volume-input {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 3px; background: var(--ink-4); border-radius: 2px; outline: none;
}
.player__volume-input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 999px; background: var(--paper); cursor: pointer;
}
.player__volume-input::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 999px; background: var(--paper); cursor: pointer; }

/* ---------- Mobile mini / expanded player ---------- */
@media (max-width: 860px) {
  .player { height: var(--player-h-mobile); }
  .player__inner {
    height: var(--player-h-mobile);
    grid-template-columns: 1fr auto;
    padding: 0 var(--sp-3);
  }
  .player__center { display: none; }
  .player__right { gap: var(--sp-2); }
  .player__volume { display: none; }

  .player.is-expanded { height: 100vh; }
  .player.is-expanded .player__inner {
    height: auto; grid-template-columns: 1fr; padding: var(--sp-3);
    display: flex; flex-direction: column; align-items: center; gap: var(--sp-5);
  }
  .player.is-expanded .player__track { flex-direction: column; text-align: center; margin-top: var(--sp-6); }
  .player.is-expanded .player__art { width: min(72vw, 320px); height: min(72vw, 320px); border-radius: var(--radius-lg); }
  .player.is-expanded .player__title { font-size: var(--step-2); font-family: var(--font-display); white-space: normal; }
  .player.is-expanded .player__center { display: flex; width: 100%; min-width: 0; }
  .player.is-expanded .player__transport { gap: var(--sp-5); }
  .player.is-expanded .player__play { width: 60px; height: 60px; }
  .player.is-expanded .player__play svg { width: 24px; height: 24px; }
  .player.is-expanded .player__right { display: none; }

  .player__expand-toggle { display: flex; }
  .player__collapse { display: none; }
  .player.is-expanded .player__collapse { display: flex; position: absolute; top: var(--sp-3); left: var(--sp-3); }
}
@media (min-width: 861px) {
  .player__expand-toggle, .player__collapse { display: none; }
}

/* GALORE ESCAPES RADIO — PHASE A PART 2 SHARED PLAYER PREMIUM UPGRADE */

.player {
  --player-art-size: 58px;
  position: fixed;
  z-index: 120;
  right: clamp(0.75rem, 2vw, 1.5rem);
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  left: clamp(0.75rem, 2vw, 1.5rem);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: clamp(18px, 2vw, 26px);
  background:
    linear-gradient(
      135deg,
      rgba(19, 20, 24, 0.97),
      rgba(8, 9, 12, 0.98)
    );
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.player::before {
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(
      circle at 12% 0%,
      rgba(255, 255, 255, 0.07),
      transparent 34%
    );
}

.player__inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns:
    minmax(220px, 0.95fr)
    minmax(330px, 1.5fr)
    minmax(180px, 0.75fr);
  gap: clamp(1rem, 2vw, 2rem);
  align-items: center;
  min-height: 88px;
  padding:
    clamp(0.85rem, 1.8vw, 1.15rem)
    clamp(1rem, 2vw, 1.5rem);
}

.player__track {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.player__art {
  width: var(--player-art-size);
  height: var(--player-art-size);
  flex: 0 0 var(--player-art-size);
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
}

.player__meta {
  min-width: 0;
}

.player__title {
  overflow: hidden;
  color: var(--text, #fff);
  font-size: clamp(0.95rem, 1.4vw, 1.08rem);
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player__album {
  overflow: hidden;
  margin-top: 0.25rem;
  color: var(--muted, rgba(255, 255, 255, 0.62));
  font-size: 0.82rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player__center {
  min-width: 0;
  display: grid;
  gap: 0.65rem;
}

.player__transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.65rem, 1.4vw, 1rem);
}

.player__play {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: var(--accent, #fff);
  color: var(--accent-text, #050505);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.32);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.player__play:hover {
  transform: scale(1.045);
  filter: brightness(1.04);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.38);
}

.player__play:active {
  transform: scale(0.98);
}

.player__play svg {
  width: 23px;
  height: 23px;
}

.player .icon-btn {
  transition:
    background-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.player .icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.085);
}

.player__seek {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 0.65rem;
  align-items: center;
}

.player__time {
  color: var(--muted, rgba(255, 255, 255, 0.58));
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.player__time:first-child {
  text-align: right;
}

.player__seek-bar {
  position: relative;
  min-width: 0;
  height: 20px;
  display: flex;
  align-items: center;
}

.player__seek-track {
  position: relative;
  width: 100%;
  height: 5px;
  overflow: visible;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.player__seek-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--accent, #fff);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.12);
}

.player__seek-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  background: #111;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}

.player__seek-bar:hover .player__seek-thumb,
.player__seek-input:focus-visible ~ .player__seek-thumb {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.player__seek-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.player__right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.player__volume {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.player__volume-input {
  width: clamp(72px, 8vw, 112px);
  accent-color: var(--accent, #fff);
}

.player__collapse {
  display: none;
}

.player__expand-toggle {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Active album rows receive stronger listening feedback. */
.track-row--active {
  position: relative;
  border-color: rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.09),
      rgba(255, 255, 255, 0.025)
    );
}

.track-row--active::before {
  position: absolute;
  top: 18%;
  bottom: 18%;
  left: 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  content: "";
  background: var(--accent, #fff);
}

.track-row--active .track-row__title {
  color: var(--text, #fff);
  font-weight: 650;
}

.track-row--active .track-row__index {
  opacity: 0;
}

.track-row--active .track-row__play-icon {
  opacity: 1;
}

/* Leave enough document space for the fixed player. */
body {
  padding-bottom:
    calc(
      118px +
      env(safe-area-inset-bottom)
    );
}

@media (max-width: 980px) {
  .player__inner {
    grid-template-columns:
      minmax(190px, 0.9fr)
      minmax(280px, 1.4fr)
      auto;
    gap: 1rem;
  }

  .player__volume-input {
    display: none;
  }
}

@media (max-width: 860px) {
  .player {
    --player-art-size: 50px;
    right: 0.65rem;
    bottom: max(0.65rem, env(safe-area-inset-bottom));
    left: 0.65rem;
    border-radius: 19px;
  }

  .player__inner {
    grid-template-columns:
      minmax(0, 1fr)
      auto;
    min-height: 72px;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
  }

  .player__track {
    min-width: 0;
  }

  .player__center {
    display: contents;
  }

  .player__transport {
    grid-column: 2;
    grid-row: 1;
  }

  .player__transport > .icon-btn {
    display: none;
  }

  .player__play {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .player__seek {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
  }

  .player__seek .player__time {
    display: none;
  }

  .player__seek-bar {
    height: 7px;
  }

  .player__seek-track {
    height: 3px;
    border-radius: 0;
  }

  .player__seek-thumb {
    display: none;
  }

  .player__right {
    display: none;
  }

  .player__collapse {
    display: none;
  }

  body {
    padding-bottom:
      calc(
        96px +
        env(safe-area-inset-bottom)
      );
  }
}

@media (max-width: 430px) {
  .player {
    right: 0.45rem;
    bottom: max(0.45rem, env(safe-area-inset-bottom));
    left: 0.45rem;
  }

  .player__inner {
    min-height: 68px;
    padding: 0.62rem 0.68rem;
  }

  .player__art {
    border-radius: 11px;
  }

  .player__album {
    max-width: 26ch;
  }

  .player__play {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .player__play,
  .player .icon-btn,
  .player__seek-thumb {
    transition: none;
  }
}


/* GALORE ESCAPES RADIO — PHASE 4 PART 1 CORE PLAYER CONTROL POLISH */

#playerStop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

#playerStop svg {
  width: 1.1rem;
  height: 1.1rem;
}

#playerStop:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

@media (hover: none) and (pointer: coarse) {
  #playerStop {
    min-width: 48px;
    min-height: 48px;
  }
}

@media (forced-colors: active) {
  #playerStop {
    forced-color-adjust: auto;
  }
}

/* GALORE ESCAPES RADIO — PHASE 4 PART 2 TIMELINE BUFFERED PROGRESS POLISH */

.player-seek__buffer {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 0%;
  border-radius: inherit;
  background: currentColor;
  opacity: 0.22;
  pointer-events: none;
}

#playerSeekFill,
#playerSeekThumb {
  position: relative;
  z-index: 2;
}

#playerSeekInput {
  min-height: 44px;
  touch-action: manipulation;
}

#playerSeekInput:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.player-bar.is-seeking #playerSeekThumb {
  transform: scale(1.15);
}

@media (hover: none) and (pointer: coarse) {
  #playerSeekInput {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #playerSeekThumb {
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .player-seek__buffer {
    background: CanvasText;
    opacity: 0.35;
  }
}

/* GALORE ESCAPES RADIO — PHASE 4 PART 3 PLAYBACK MODE CONTROLS */

#playerShuffle,
#playerRepeat {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
}

#playerShuffle svg,
#playerRepeat svg {
  width: 1.15rem;
  height: 1.15rem;
}

#playerShuffle.is-active,
#playerRepeat.is-active {
  opacity: 1;
  box-shadow: inset 0 0 0 2px currentColor;
}

#playerRepeat[data-repeat-mode="one"] {
  position: relative;
}

#playerRepeat[data-repeat-mode="one"]::after {
  content: "1";
  position: absolute;
  inset-inline-end: 2px;
  inset-block-end: 1px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
}

#playerShuffle:focus-visible,
#playerRepeat:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

@media (hover: none) and (pointer: coarse) {
  #playerShuffle,
  #playerRepeat {
    min-width: 48px;
    min-height: 48px;
  }
}

/* GALORE ESCAPES RADIO — PHASE 4 PART 6 MEDIA ERROR UX */

.player-failure {
  position: absolute;
  inset-inline: var(--sp-3);
  bottom: calc(100% + var(--sp-2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid currentColor;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--paper);
}

.player-failure[hidden] {
  display: none;
}

.player-failure__content {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.player-failure__title {
  font-weight: 700;
}

.player-failure__message {
  overflow-wrap: anywhere;
}

.player-failure__actions {
  display: flex;
  flex: 0 0 auto;
  gap: var(--sp-2);
}

.player-failure__actions button {
  min-height: 44px;
  touch-action: manipulation;
}

.player-failure__actions button:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .player-failure {
    align-items: stretch;
    flex-direction: column;
  }

  .player-failure__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .player-failure__actions button {
    width: 100%;
  }
}


/* ==========================================================
   GALORE ESCAPES RADIO — PHASE 1 PART 4 MOBILE CORE TRANSPORT

   Existing DOM controls only:
     #playerPrev
     #playerPlay
     #playerNext
     #playerStop

   Presentation authority only.
   No playback, queue or Jahcore runtime authority changed.
   ========================================================== */

@media (max-width: 860px) {

  #playerPrev,
  #playerPlay,
  #playerNext {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;

    align-items: center !important;
    justify-content: center !important;

    flex: 0 0 48px !important;

    width: 48px !important;
    height: 48px !important;

    min-width: 48px !important;
    min-height: 48px !important;

    max-width: 48px !important;
    max-height: 48px !important;

    pointer-events: auto !important;
    touch-action: manipulation !important;

    transform: none !important;
  }

  #playerStop {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;

    align-items: center !important;
    justify-content: center !important;

    flex: 0 0 44px !important;

    min-width: 44px !important;
    min-height: 44px !important;

    pointer-events: auto !important;
    touch-action: manipulation !important;
  }

  .player__controls {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    flex-wrap: wrap !important;
    gap: 8px !important;

    min-width: 0 !important;
    max-width: 100% !important;

    overflow: visible !important;
  }
}

@media (max-width: 420px) {

  #playerPrev,
  #playerPlay,
  #playerNext {
    flex-basis: 46px !important;

    width: 46px !important;
    height: 46px !important;

    min-width: 46px !important;
    min-height: 46px !important;

    max-width: 46px !important;
    max-height: 46px !important;
  }

  #playerStop {
    flex-basis: 42px !important;

    width: 42px !important;
    height: 42px !important;

    min-width: 42px !important;
    min-height: 42px !important;

    max-width: 42px !important;
    max-height: 42px !important;
  }

  .player__controls {
    gap: 6px !important;
  }
}

#playerPrev:focus-visible,
#playerPlay:focus-visible,
#playerNext:focus-visible,
#playerStop:focus-visible {
  outline: 3px solid currentColor !important;
  outline-offset: 3px !important;
}

