/* ==========================================================================
   gh-audio-player — styles

   Theme it entirely by setting these custom properties on .gh-audio-player
   (or any ancestor). Fallbacks assume a light background.

     --gh-accent        main brand colour (play button, fills, viz)  [red]
     --gh-accent-dark   darker accent for the play-button hover
     --gh-text          primary text colour
     --gh-tan           secondary/label colour
     --gh-bg            panel background
     --gh-radius        corner radius
     --gh-font          font for the track title
     --gh-font-ui       font for labels, times and track numbers  [inherit]
     --gh-neutral       RGB triplet for faint lines/fills — borders, slider
                        tracks, muted text/icons, hover/active  [61, 53, 48]
     --gh-play-bg       play-button background; accepts a gradient  [accent]
     --gh-play-bg-hover play-button hover background                [accent-dark]

   --gh-accent-rgb (an RGB triplet) is derived from --gh-accent by the JS so
   the slider shadows/glows follow the accent; a static fallback is used if JS
   is unavailable.

   For a dark theme, set --gh-neutral to a light triplet (e.g. cream) to flip
   every faint grey at once.
   ========================================================================== */

.gh-audio-player {
  --gh-progress-h: 1.5rem;   /* progress-row height; the volume pins to its centreline */
  --gh-gutter: 2.75rem;      /* space reserved on the right for the volume slider */
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: stretch;
  margin: 2.5rem 0;
}
.gh-audio-player > audio { display: none; }

/* --- Now Playing panel --------------------------------------------------- */
.gh-audio-player__display {
  background: var(--gh-bg, #ffffff);
  border: 1px solid rgba(var(--gh-neutral, 61, 53, 48), 0.15);
  border-radius: var(--gh-radius, 6px);
  padding: clamp(1.25rem, 3vw, 2rem);
  padding-right: var(--gh-gutter);   /* reserve the gutter for the volume slider */
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Controls + progress grouped so the volume can pin to the progress bar. */
.gh-audio-player__transport {
  position: relative;                 /* anchors the vertical volume */
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.gh-audio-player__now {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.gh-audio-player__label {
  font-size: 0.72rem;
  font-family: var(--gh-font-ui, inherit);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gh-tan, #C4A882);
}
.gh-audio-player__title {
  font-family: var(--gh-font, Georgia, 'Times New Roman', serif);
  font-size: clamp(1.2rem, 2.5vw, 1.4rem);
  color: var(--gh-text, #3D3530);
  line-height: 1.25;
  min-height: 1.25em;
}

/* --- Controls ------------------------------------------------------------ */
.gh-audio-player__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
}
.gh-audio-player__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: rgba(var(--gh-neutral, 61, 53, 48), 0.5);
  transition: color 0.2s ease, transform 0.2s ease;
  border-radius: 50%;
}
.gh-audio-player__btn svg { pointer-events: none; }
.gh-audio-player__btn--prev svg,
.gh-audio-player__btn--next svg { width: 28px; height: 28px; }
.gh-audio-player__btn:hover { color: var(--gh-accent, #8B1A1A); transform: scale(1.1); }
.gh-audio-player__btn:disabled { color: rgba(var(--gh-neutral, 61, 53, 48), 0.2); pointer-events: none; }
.gh-audio-player__btn--play {
  width: 52px;
  height: 52px;
  background: var(--gh-accent, #8B1A1A);
  color: #ffffff;
  border-radius: 50%;
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.gh-audio-player__btn--play svg { width: 26px; height: 26px; }
.gh-audio-player__btn--play:hover {
  background: var(--gh-play-bg-hover, var(--gh-accent-dark, #6b1414));
  box-shadow: 0 4px 16px rgba(var(--gh-accent-rgb, 139, 26, 26), 0.3);
  transform: scale(1.05);
  color: #ffffff;
}

/* --- Progress + time ----------------------------------------------------- */
.gh-audio-player__progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  height: var(--gh-progress-h);   /* centred track line for the volume to meet */
}
.gh-audio-player__time {
  font-size: 0.78rem;
  font-family: var(--gh-font-ui, inherit);
  letter-spacing: 0.04em;
  color: rgba(var(--gh-neutral, 61, 53, 48), 0.7);
  min-width: 2.6rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- Range inputs (scrubber + volume share the thumb look) --------------- */
.gh-audio-player__scrubber {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  outline: none;
  flex: 1;
  /* Fill the whole progress row so the click/tap target is a comfortable band
     rather than the 3px line. The track stays vertically centred, so this only
     loosens the hit box — the visual is unchanged. */
  height: var(--gh-progress-h);
  --pct: 0%;
}
.gh-audio-player__scrubber::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--gh-accent, #8B1A1A) var(--pct), rgba(var(--gh-neutral, 61, 53, 48), 0.15) var(--pct));
}
.gh-audio-player__scrubber::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(var(--gh-neutral, 61, 53, 48), 0.15);
}
.gh-audio-player__scrubber::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gh-accent, #8B1A1A);
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(var(--gh-accent-rgb, 139, 26, 26), 0.35);
  transition: transform 0.2s ease;
}
.gh-audio-player__scrubber::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gh-accent, #8B1A1A);
  border: none;
  box-shadow: 0 0 6px rgba(var(--gh-accent-rgb, 139, 26, 26), 0.35);
}
.gh-audio-player__scrubber:hover::-webkit-slider-thumb { transform: scale(1.25); }

/* --- Volume: small vertical slider, bottom flush with the progress bar ---- */
.gh-audio-player__volume {
  position: absolute;
  bottom: calc(var(--gh-progress-h) / 2);   /* bottom flush with the progress track */
  right: calc(0.85rem - var(--gh-gutter));  /* 0.85rem in from the panel edge, in the gutter */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.gh-audio-player__volume-icon {
  width: 15px;
  height: 15px;
  color: rgba(var(--gh-neutral, 61, 53, 48), 0.5);
  flex-shrink: 0;
}
/* Safari's support for vertical (writing-mode) range inputs is unreliable: it
   ignores the custom track/thumb sizing and paints a thick, janky slider. So
   style a regular HORIZONTAL range and rotate it 90°. The negative margins
   collapse its layout box from 80x13 to 13x80 so it sits flush in the gutter. */
.gh-audio-player__volume-input {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;                 /* length, before rotation */
  height: 13px;                /* thickness */
  margin: 33.5px -33.5px;      /* (80 - 13) / 2 — collapse footprint to 13x80 */
  transform: rotate(-90deg);   /* min at bottom, max at top */
  background: transparent;
  cursor: pointer;
  --pct: 80%;
}
.gh-audio-player__volume-input::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--gh-accent, #8B1A1A) var(--pct), rgba(var(--gh-neutral, 61, 53, 48), 0.12) var(--pct));
}
.gh-audio-player__volume-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gh-accent, #8B1A1A);
  margin-top: -5px;
  box-shadow: 0 0 6px rgba(var(--gh-accent-rgb, 139, 26, 26), 0.35);
}
.gh-audio-player__volume-input::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(var(--gh-neutral, 61, 53, 48), 0.12);
}
.gh-audio-player__volume-input::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--gh-accent, #8B1A1A);
  border: none;
}

/* --- Visualiser ---------------------------------------------------------- */
/* flex-basis is 0, not auto, on purpose. A <canvas>'s intrinsic size IS its
   width/height attributes, which the JS rewrites from the measured box on
   every resize. With flex-basis:auto that intrinsic size feeds back into the
   layout (the canvas grows the panel, the observer fires, it grows again on
   the next pass); flex-basis:0 removes the canvas' intrinsic size from layout
   entirely, breaking the loop. */
.gh-audio-player__viz {
  display: block;
  width: 100%;
  flex: 1 1 0;
  min-height: 90px;
}

/* --- Track list ---------------------------------------------------------- */
.gh-audio-player__tracklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gh-audio-player__track {
  display: grid;
  grid-template-columns: 2.2rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--gh-radius, 6px);
  cursor: pointer;
  transition: background 0.15s ease;
}
.gh-audio-player__track:hover { background: rgba(var(--gh-neutral, 61, 53, 48), 0.05); }
.gh-audio-player__track.is-active { background: rgba(var(--gh-neutral, 61, 53, 48), 0.08); }
.gh-audio-player__track:focus-visible { outline: 2px solid var(--gh-accent, #8B1A1A); outline-offset: -2px; }
.gh-audio-player__track-num {
  font-size: 0.8rem;
  font-family: var(--gh-font-ui, inherit);
  letter-spacing: 0.06em;
  color: rgba(var(--gh-neutral, 61, 53, 48), 0.62);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.gh-audio-player__track-title {
  font-size: 1rem;
  color: var(--gh-text, #3D3530);
}
.gh-audio-player__track.is-active .gh-audio-player__track-title { font-weight: 600; }
.gh-audio-player__track-duration {
  font-size: 0.8rem;
  font-family: var(--gh-font-ui, inherit);
  color: rgba(var(--gh-neutral, 61, 53, 48), 0.62);
  letter-spacing: 0.04em;
  min-width: 2.8rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- Small screens ------------------------------------------------------- */
@media (max-width: 720px) {
  .gh-audio-player { grid-template-columns: 1fr; }
  .gh-audio-player__display { padding-right: clamp(1.25rem, 3vw, 2rem); }
  .gh-audio-player__volume { display: none; } /* use device volume */
  .gh-audio-player__viz { display: none; }    /* here it only pushes the list down */
}
