/* A floating bar, not a full-width strip.
   Stretched edge to edge on a desktop it read as browser chrome — a black band
   with a play button adrift at one end and a volume slider adrift at the other,
   a metre of empty space between them. It only ever holds a few controls, so it
   is sized to its contents and floated clear of the corner. */
.cw-player {
  position: fixed;
  /* Bottom right, not centre: centred it covered a headline at almost every
     scroll position, and the corner is where a persistent widget belongs. */
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9999;
  width: max-content;
  max-width: calc(100vw - 2rem);
  /* The head unit: the instrument surface the hero's LED readout belongs
     to, on the same cell grid. Solid, not glass — a display is opaque. */
  background: var(--icrt-instrument, #121316);
  color: #fff;
  border: 1px solid var(--icrt-instrument-line, rgba(255, 255, 255, .08));
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
  font-size: 14px;
  isolation: isolate;
  overflow: hidden;
}

.cw-player::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--icrt-dot-off, #2b2e35);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7'%3E%3Crect x='2' y='2' width='3' height='3' rx='.6'/%3E%3C/svg%3E") 0 0 / 7px 7px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='7'%3E%3Crect x='2' y='2' width='3' height='3' rx='.6'/%3E%3C/svg%3E") 0 0 / 7px 7px;
  opacity: .55;
  pointer-events: none;
}

.cw-player__inner {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .45rem 1.1rem .45rem .45rem;
}

/* --- artwork -------------------------------------------------------------
   Every music player is read artwork-first. Radio has none, so the tile
   carries the artist's initials over a colour derived from their name — the
   same artist always looks the same, and it stays inside the station's blues
   rather than picking a random hue. */

.cw-player__art {
  flex: 0 0 auto;
  order: -1;
  width: 46px;
  height: 46px;
  border-radius: .55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, #0b2f6b 0%, #1160d4 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
}

.cw-player__mark {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
}

/* --- the track ----------------------------------------------------------- */

.cw-player__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: .1rem;
  min-width: 0;
  /* A long title must scroll its own text rather than stretch the bar. */
  max-width: 14rem;
}

.cw-player__track {
  font-size: .86rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cw-player__artist {
  font-size: .76rem;
  color: #9aa3b1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full width is right on a phone, where a floating pill would cover content
   and leave too little room for the controls. */
@media (max-width: 40rem) {
  .cw-player {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-top: 2px solid #1160d4;
  }

  .cw-player__inner { padding: .5rem 1rem; }
}

.cw-player__toggle {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  /* border-box and an explicit padding reset: the theme's own button styles
     add horizontal padding, and with the default content-box that turned a
     40px circle into a wide ellipse. */
  box-sizing: border-box;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--icrt-ink, #14161a);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease;
}

.cw-player__toggle:hover { background: #fff; transform: scale(1.06); }

/* Sounding, not just asked to: the disc lights in the signal colour. */
.cw-player[data-playing="true"] .cw-player__toggle,
.cw-player[data-playing="true"] .cw-player__toggle:hover { background: var(--icrt-signal, #ff7a1a); }

.cw-player__icon {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 0 7px 11px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 3px;
}

.cw-player[data-state="playing"] .cw-player__icon {
  width: 11px;
  height: 13px;
  border: 0;
  margin-left: 0;
  background: linear-gradient(to right, currentColor 0 3px, transparent 3px 8px, currentColor 8px 11px);
}

.cw-player__meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  flex: 1 1 auto;
  /* Left aligned at every width: the theme centres inline text, which left
     the title floating in the middle of its column above a left-aligned
     artist line. */
  text-align: left;
  align-items: flex-start;
}

/* The two-tone live mark: a signal square holding a dark dot, then Live in
   a light box. Gone once the log has gone quiet: the bar claims nothing. */
.cw-player__badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: 0 .4rem 0 0;
  border-radius: 4px;
  overflow: hidden;
  background: #eef1f5;
  color: var(--icrt-ink, #14161a);
  font-size: .7rem;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: 0;
  text-transform: none;
}

.cw-player__badge::before {
  content: "";
  display: block;
  width: 16px;
  height: 18px;
  background-color: var(--icrt-signal, #ff7a1a);
  background-image: radial-gradient(circle, var(--icrt-ink, #14161a) 2.5px, transparent 3px);
}

.cw-player[data-error] .cw-player__badge::before { background-color: var(--icrt-dot-off, #2b2e35); }
.cw-player[data-stale="true"] .cw-player__badge { display: none; }

.cw-player__now {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cw-player__volume-wrap { flex: 0 0 auto; }
.cw-player__volume { width: 90px; vertical-align: middle; }


/* Stale: the newest logged play is not what is on air now, so the badge
   stays visible and says when it went out, in sentence case, not shouting. */

@media (max-width: 600px) {
  .cw-player__volume-wrap { display: none; }
}

/* --- volume ---------------------------------------------------------------
   A bare <input type=range> renders as the platform's default control, which
   is the single most dated thing on the page. */

.cw-player__volume-wrap { display: flex; align-items: center; }

.cw-player__volume-wrap {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding-left: .35rem;
  border-left: 1px solid rgba(255, 255, 255, .1);
}

.cw-player__spk { width: 15px; height: 15px; color: #8b95a5; flex: 0 0 auto; }

.cw-player__vol-box { position: relative; display: flex; align-items: center; height: 24px; }
.cw-player__vol { display: flex; gap: 3px; }
/* One cell tall: a level to set, not a signal to watch — beside the meter,
   two rows of amber read as a second meter. */
.cw-player__vol i {
  display: block;
  width: 4px;
  height: 7px;
  background: var(--icrt-dot-off, #2b2e35);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Crect y='1.5' width='4' height='4' rx='.6'/%3E%3C/svg%3E") 0 0 / 4px 7px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Crect y='1.5' width='4' height='4' rx='.6'/%3E%3C/svg%3E") 0 0 / 4px 7px;
}
.cw-player__vol i[data-on] { background: var(--icrt-signal, #ff7a1a); }

/* The real control, invisible, over the cells: drag, click and arrow keys. */
.cw-player .cw-player__vol-box input.cw-player__volume[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cw-player .cw-player__vol-box input.cw-player__volume[type="range"]:focus-visible { opacity: 1; }

/* The theme styles bare inputs as tall rounded fields, which turned this into
   something that read as an iOS toggle rather than a volume slider. Element
   qualified and reset outright — the same fight the buttons needed. */
.cw-player .cw-player__volume-wrap input.cw-player__volume[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 62px;
  height: 3px;
  min-height: 0;
  max-height: 3px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: none;
  outline: none;
  cursor: pointer;
}

.cw-player .cw-player__volume-wrap input.cw-player__volume[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.cw-player .cw-player__volume-wrap input.cw-player__volume[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  border: 0;
}

.cw-player .cw-player__volume-wrap input.cw-player__volume[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

/* A softer shell: the heavy black slab with a hard shadow read as a widget
   from another decade. */
.cw-player {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.cw-player__now { font-size: .86rem; font-weight: 600; }

/* --- mobile ---------------------------------------------------------------
   Full width, and the volume control goes: a slider is a poor target on a
   phone and the hardware keys already do the job. */

@media (max-width: 40rem) {
  .cw-player__inner { gap: .65rem; padding: .4rem .8rem .4rem .4rem; }
  .cw-player__volume-wrap { display: none; }
  /* Left aligned and hard against the artwork. The theme centres inline text
     inside the bar, which left the track drifting into the middle with a hand's
     width of nothing between it and the play button. */
  .cw-player__meta { max-width: none; flex: 1 1 auto; text-align: left; align-items: flex-start; }
  .cw-player__art { width: 38px; height: 38px; }
}

/* Before the first poll lands there is no track to show, so the station name
   stands alone and the artwork would be a meaningless coloured square. */
.cw-player:not([data-has-track]) .cw-player__art { display: none; }
/* The mark stands beside the artist's name at all times: it is what says
   "live", or "last played 16:53" when the log has gone quiet. */
.cw-player__artist { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; }
.cw-player__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-player__name:empty { display: none; }

/* --- the level meter --------------------------------------------------------
   Twelve columns of four LED cells, lit from the bottom by the audio actually
   sounding (data-lit, written by the analyser loop). Unlit while paused. When
   the analyser cannot read the stream the bar says data-meter="fallback" and
   the columns pulse decoratively while playing, never claiming a level. */

@property --lit { syntax: '<number>'; inherits: false; initial-value: 0; }

.cw-player__vu { display: flex; align-items: flex-end; gap: 3px; height: 28px; flex: 0 0 auto; }

.cw-player__vu i {
  display: block;
  width: 4px;
  height: 28px;
  background: linear-gradient(to top, var(--icrt-signal, #ff7a1a) calc(var(--lit, 0) * 7px), var(--icrt-dot-off, #2b2e35) 0);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Crect y='1.5' width='4' height='4' rx='.6'/%3E%3C/svg%3E") 0 0 / 4px 7px;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='7'%3E%3Crect y='1.5' width='4' height='4' rx='.6'/%3E%3C/svg%3E") 0 0 / 4px 7px;
}

.cw-player__vu i[data-lit="1"] { --lit: 1; }
.cw-player__vu i[data-lit="2"] { --lit: 2; }
.cw-player__vu i[data-lit="3"] { --lit: 3; }
.cw-player__vu i[data-lit="4"] { --lit: 4; }

.cw-player[data-meter="fallback"][data-playing="true"] .cw-player__vu i { animation: cw-vu 1.1s ease-in-out infinite alternate; }
.cw-player[data-meter="fallback"][data-playing="true"] .cw-player__vu i:nth-child(3n) { animation-delay: -.4s; }
.cw-player[data-meter="fallback"][data-playing="true"] .cw-player__vu i:nth-child(3n + 1) { animation-delay: -.8s; }

@keyframes cw-vu {
  from { --lit: 1; }
  to   { --lit: 4; }
}

/* Motion in the fallback is decoration, and decoration never overrides a
   stated preference for less of it. The live meter is a reading and stays. */
@media (prefers-reduced-motion: reduce) {
  .cw-player[data-meter="fallback"] .cw-player__vu i { animation: none; --lit: 2; }
}

@media (max-width: 40rem) {
  .cw-player__eq { display: none !important; }
}

.cw-player a.cw-player__track { color: inherit; text-decoration: none; }
.cw-player a.cw-player__track[href]:hover { text-decoration: underline; }
.cw-player a.cw-player__track:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
