/* The hidden music trigger: the word "magic" in the footer (js.src/secretMusic.js).
   A real button made to read as the text around it, text cursor included.
   Font and colour already come from base.css (`button { font: inherit; color: inherit; }`). */
.secret-magic {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  cursor: text;
  user-select: text;
}
.secret-magic:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Pixie dust: a few glowing specks that drift up and fade. Theme colours, so
   dark, light and pink each get their own. A visitor who asks for less motion
   gets none: secretMusic.js never creates them (prefersLessMotion). */
.secret-magic-speck {
  position: absolute;
  top: 45%;
  left: var(--start, 50%);
  width: var(--size, 3px);
  height: var(--size, 3px);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 4px currentColor;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
  animation: secret-magic-drift 900ms ease-out var(--delay, 0ms) forwards;
}
.secret-magic-speck.is-alt { color: var(--accent-2); }

@keyframes secret-magic-drift {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x, 0px)), var(--y, -16px)) scale(1); }
}

/* The floating music player (js.src/secretMusic.js builds it on the first
   start). Smoked glass in every theme: a dark tint over a blur of the page,
   so its text colours are its own, not the theme's. Measured with
   contrast-check.py against the worst case, the smoke over a white page
   (#525458): text #f4f6f9 7.01:1, muted #c9ced6 4.80:1; focus rings in the accent,
   #ff9f1c 3.70:1 and pink's #ff9dd5 3.99:1 (UI parts need 3:1); icons on
   the accent button, #101218 on #ff9f1c 9.12:1, #2a071c on #ff9dd5 9.63:1.
   Pink's main accent #ff5cbd measured 2.72:1 there, so the player uses its
   second one. */
.secret-player {
  --sp-text: #f4f6f9;
  --sp-muted: #c9ced6;
  --sp-line: rgba(255, 255, 255, 0.14);
  --sp-hover: rgba(255, 255, 255, 0.12);
  --sp-accent: #ff9f1c;
  --sp-playing: #4ade80;
  --sp-problem: #ff8a80;
  --sp-accent-ink: #101218;
  --sp-pad: 12px;
  --sp-fade: 10px;
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9000;
  display: grid;
  gap: 6px;
  width: min(320px, calc(100vw - 32px));
  padding: 8px var(--sp-pad) 10px;
  border: 1px solid var(--sp-line);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 45%),
    rgba(14, 16, 22, 0.78);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: var(--sp-text);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  animation: secret-player-in 180ms ease-out;
}
html[data-theme="pink"] .secret-player {
  --sp-accent: #ff9dd5;
  --sp-accent-ink: #2a071c;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .secret-player { background: rgba(14, 16, 22, 0.94); }
}
.secret-player.is-dragging { user-select: none; }
/* Minimize and expand fly the player between its spot and the corner. */
.secret-player.is-flying { transition: left 420ms cubic-bezier(0.22, 1, 0.36, 1), top 420ms cubic-bezier(0.22, 1, 0.36, 1); }

/* The top bar. Its 32px buttons draw 16px icons whose marks sit 4px inside,
   so pulling the bar out by 12px puts the grip's dots on the title's left
   edge and the X on the controls' right edge (Jason, 2026-11-17: the X was
   not aligned). */
.secret-player-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0;
  margin: 0 -12px;
  cursor: grab;
  touch-action: none;
}
.secret-player.is-dragging .secret-player-bar { cursor: grabbing; }
/* The header: a made-up station name with a dot for the state beside it.
   The dot differs by shape, not only colour (WCAG 1.4.1): playing is a
   solid green dot that pulses, loading an accent ring with a turning gap,
   paused a solid grey dot, unavailable a red ring (colours: Jason,
   2026-11-17). On the worst-case smoke green 4.35:1, red 3.32:1, accent
   3.70:1 (pink 3.99:1) and grey 4.80:1, over the 3:1 a meaningful graphic
   needs. The state in words is kept for screen readers. */
.secret-player-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--sp-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.secret-player-station { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.secret-player-state {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
/* So a screen reader says "M-ROCJR 73.0 FM, Paused", not "FMPaused". The
   state is a polite live region, so play and pause are announced too
   (ui-checker, 2026-11-17). */
.secret-player-state::before { content: ", "; }
.secret-player-dot {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sp-muted);
}
/* Playing: the box stays 8px and a circle painted inside it pulses from a
   4px radius to 2.8px and back (70%). Not a transform: Firefox rounds both
   edges of a small shrinking box to whole pixels, so a scaled 8px dot could
   only be 8px or 6px across and jumped between them (Jason, 2026-11-17;
   measured in Firefox 160, and a bare dot on an empty page did the same).
   A registered length can be animated smoothly, and painting the circle
   rounds nothing. The 1px soft edge stands in for the edge smoothing a
   rounded box gets. */
@property --sp-dot-r {
  syntax: "<length>";
  inherits: false;
  initial-value: 4px;
}
.secret-player[data-state="playing"] .secret-player-dot {
  /* A browser without @property still paints a solid dot (ui-checker); the
     animation outranks this wherever it runs. */
  --sp-dot-r: 4px;
  background: radial-gradient(circle, var(--sp-playing) calc(var(--sp-dot-r) - 0.5px), transparent calc(var(--sp-dot-r) + 0.5px));
  animation: secret-player-pulse 1.6s ease-in-out infinite;
}
.secret-player[data-state="loading"] .secret-player-dot {
  border: 2px solid var(--sp-accent);
  border-right-color: transparent;
  background: none;
  animation: secret-player-turn 0.9s linear infinite;
}
.secret-player[data-state="problem"] .secret-player-dot {
  border: 2px solid var(--sp-problem);
  background: none;
}
@keyframes secret-player-pulse {
  0%, 100% { --sp-dot-r: 4px; }
  50% { --sp-dot-r: 2.8px; }
}
@keyframes secret-player-turn { to { transform: rotate(360deg); } }

.secret-player-icon,
.secret-player-button {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--sp-text);
  cursor: pointer;
}
.secret-player-grip { cursor: grab; color: var(--sp-muted); }
.secret-player-icon svg,
.secret-player-button svg { width: 16px; height: 16px; fill: currentColor; }
.secret-player-icon:hover,
.secret-player-button:hover:not(:disabled) { background: var(--sp-hover); }
.secret-player-icon:focus-visible,
.secret-player-button:focus-visible,
.secret-player-volume:focus-visible,
.secret-player-seek:focus-visible,
.secret-player-source:focus-visible {
  outline: 2px solid var(--sp-accent);
  outline-offset: 2px;
  /* One ring only: base.css draws the theme's ring as a box-shadow on every
     :focus-visible, and the light theme's darker accent would show beside it. */
  box-shadow: none;
}
.secret-player-button:disabled { opacity: 0.4; cursor: not-allowed; }
.secret-player-button.is-main {
  width: 36px;
  height: 36px;
  background: var(--sp-accent);
  color: var(--sp-accent-ink);
}
.secret-player-button.is-main:hover:not(:disabled) { background: var(--sp-accent); filter: brightness(1.08); }
.secret-player-button.is-main svg { width: 15px; height: 15px; }

/* Title and composer: one line each. Too long for the player, the line
   slides sideways to show the rest, then starts again from the beginning
   (the distance and time come from secretMusic.js), and stops under the
   pointer. With less motion asked for, it stays still (see the end). */
.secret-player-now { min-width: 0; }
.secret-player-line {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.secret-player-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.secret-player-meta { color: var(--sp-muted); font-size: 12px; line-height: 1.4; }
.secret-player-line.is-scrolling {
  text-overflow: clip;
  /* Soft ends, so letters fade out at the edges instead of being cut. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--sp-fade), #000 calc(100% - var(--sp-fade)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--sp-fade), #000 calc(100% - var(--sp-fade)), transparent);
}
/* The text gets a fade's width of room on each side, so at rest the first
   letter and at the end the last letter sit clear of the fades, fully shown
   (Jason, 2026-11-17: both ends were dimmed). In the full player the line
   reaches out into the side padding by the same width, so the text still
   lines up with the lines that don't slide. */
.secret-player:not(.is-minimized) .secret-player-line.is-scrolling { margin-inline: calc(-1 * var(--sp-fade)); }
.secret-player-line.is-scrolling .secret-player-scroll {
  display: inline-block;
  padding-inline: var(--sp-fade);
  animation: secret-player-slide var(--scroll-time, 8s) linear infinite;
}
/* Held still under the pointer, while any part of the player has keyboard
   focus, or after a tap or click on the line (secretMusic.js toggles
   is-held), so mouse, keyboard and touch can all stop it (WCAG 2.2.2).
   Keyboard focus only (:focus-visible): a mouse click on a button leaves it
   focused too, and minimizing would otherwise freeze the ticker below. */
.secret-player-line.is-scrolling:hover .secret-player-scroll,
.secret-player:has(:focus-visible) .secret-player-line.is-scrolling .secret-player-scroll,
.secret-player-line.is-scrolling.is-held .secret-player-scroll,
.secret-player-now.is-ticker:hover :is(.secret-player-scroll, .secret-player-ticker-station),
.secret-player:has(:focus-visible) .secret-player-now.is-ticker :is(.secret-player-scroll, .secret-player-ticker-station),
.secret-player-title.is-held .secret-player-scroll,
.secret-player-title.is-held ~ .secret-player-ticker-station { animation-play-state: paused; }
/* One way only: a pause to read the start, the slide to the end (65% of the
   loop, matching SLIDE_SHARE in secretMusic.js), a short pause there, then a
   fade out, a jump back to the start while unseen, and a fade in (Jason,
   2026-11-17: sliding back left the start cut off). */
@keyframes secret-player-slide {
  0%, 15% { transform: translateX(0); opacity: 1; animation-timing-function: ease-in-out; }
  80%, 88% { transform: translateX(var(--scroll-distance, 0px)); opacity: 1; }
  92% { transform: translateX(var(--scroll-distance, 0px)); opacity: 0; animation-timing-function: step-end; }
  93% { transform: translateX(0); opacity: 0; }
  97%, 100% { transform: translateX(0); opacity: 1; }
}

/* Progress: the time so far on the left, the track's length on the right,
   and between them a slider that follows the track and jumps when moved. */
.secret-player-progress {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.secret-player-elapsed { min-width: 4ch; text-align: right; }
.secret-player-total { min-width: 4ch; }
.secret-player-seek,
.secret-player-volume {
  min-width: 0;
  margin: 0;
  accent-color: var(--sp-accent);
}
.secret-player-seek { width: 100%; }
.secret-player-time {
  color: var(--sp-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Controls: volume at the left edge, previous / play / next in the middle,
   and the source link floating at the right edge. The link is placed on top
   (position: absolute), so it never changes the player's size. */
.secret-player-controls {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr);
  align-items: center;
  gap: 4px;
}
.secret-player-volume-group { position: relative; justify-self: start; }
.secret-player-volume-button { color: var(--sp-muted); }
.secret-player-volume-button[aria-expanded="true"] { background: var(--sp-hover); color: var(--sp-text); }
/* The pop-up slider, above the speaker button, in the same smoke. */
.secret-player-volume-pop {
  position: absolute;
  bottom: calc(100% + 6px);
  left: -4px;
  z-index: 1;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--sp-line);
  border-radius: 999px;
  background: rgba(14, 16, 22, 0.96);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.secret-player-volume-pop[hidden] { display: none; }
.secret-player-volume { width: 120px; }
.secret-player-source {
  position: absolute;
  top: 50%;
  right: 0;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--sp-muted);
  transform: translateY(-50%);
}
.secret-player-source[hidden] { display: none; }
.secret-player-source svg { width: 14px; height: 14px; }
.secret-player-source:hover { background: var(--sp-hover); color: var(--sp-text); }

/* Minimized: one row (grip, play, the sliding title, expand, close) with
   the progress as a thin line along the bottom edge. The wrappers step
   aside (display: contents) so their buttons join the one row. */
.secret-player.is-minimized {
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px;
  width: min(280px, calc(100vw - 32px));
  padding: 6px 4px 8px;
  border-radius: 999px;
}
.secret-player.is-minimized .secret-player-bar,
.secret-player.is-minimized .secret-player-now { display: contents; }
.secret-player.is-minimized .secret-player-status,
.secret-player.is-minimized .secret-player-meta,
.secret-player.is-minimized .secret-player-progress,
.secret-player.is-minimized .secret-player-controls,
.secret-player.is-minimized .secret-player-source { display: none; }
.secret-player-mini-play { display: none; }
.secret-player.is-minimized .secret-player-grip { order: 1; }
.secret-player.is-minimized .secret-player-mini-play { display: inline-grid; order: 2; width: 30px; height: 30px; }
.secret-player.is-minimized .secret-player-title { order: 3; grid-area: 1 / 3; font-size: 13px; }
/* Minimized, every title is a ticker (Jason, 2026-11-17): it comes in at
   the right edge, crosses to the left and leaves, then the station name
   fades in over the same spot, holds and fades out, and the title comes
   round again. secretMusic.js writes the two keyframes, since the share of
   the loop each part takes depends on the title's length. */
.secret-player-ticker-station { display: none; }
.secret-player.is-minimized .secret-player-now.is-ticker .secret-player-title {
  text-overflow: clip;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--sp-fade), #000 calc(100% - var(--sp-fade)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--sp-fade), #000 calc(100% - var(--sp-fade)), transparent);
}
.secret-player.is-minimized .secret-player-now.is-ticker .secret-player-title .secret-player-scroll {
  display: inline-block;
  /* Longhands, not the shorthand: the shorthand would reset the paused
     state that the hover, focus and tap rules above set. */
  animation-name: secret-player-ticker;
  animation-duration: var(--ticker-time, 10s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.secret-player.is-minimized .secret-player-now.is-ticker .secret-player-ticker-station {
  display: block;
  grid-area: 1 / 3;
  justify-self: center;
  max-width: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none; /* a tap goes through to the title line, which holds it */
  animation-name: secret-player-ticker-station;
  animation-duration: var(--ticker-time, 10s);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.secret-player.is-minimized .secret-player-minimize { order: 4; }
.secret-player.is-minimized .secret-player-close { order: 5; }
.secret-player.is-minimized::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 3px;
  left: 22px;
  height: 2px;
  border-radius: 2px;
  /* The fill only: against a grey unfilled part the orange measured 2.32:1
     (a meaningful graphic needs 3:1); against the smoke it is 3.70:1. */
  background: linear-gradient(to right, var(--sp-accent) calc(var(--progress, 0) * 100%), transparent 0);
  pointer-events: none;
}

@keyframes secret-player-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .secret-player { animation: none; }
  .secret-player.is-flying { transition: none; }
  .secret-player-line.is-scrolling .secret-player-scroll { animation: none; }
  .secret-player-now.is-ticker :is(.secret-player-scroll, .secret-player-ticker-station) { animation: none; }
  .secret-player-dot { animation: none !important; }
  /* No sliding, so the full player shows long lines in full, wrapped (a
     hover tooltip would not survive nativeTooltipCleanup.js). The one-row
     minimized player keeps its "…". */
  .secret-player:not(.is-minimized) .secret-player-line { white-space: normal; overflow-wrap: anywhere; }
}
